It is a common K idiom to define a programming language's syntax with a top-sort of well-formed programs (e.g. Pgm
) and then to restrict the <k>
cell to have this sort in the configuration declaration using the special $PGM
variable which is passed automatically by krun
. This prevents users from executing programs with krun
that are not well-formed. My question is:
- Are the sort of cells checked only at start-up time or after each rule evaluation?
- Do different cells show different behavior depending on their identity (e.g. the
<k>
cell) or how they are typed (e.g. user-defined types versus builtin types)?
Here is a partial example to show what I mean:
configuration
<mylang>
<k> $PGM:Pgm </k>
<env> .Env:Env </env> // Env is a custom map structure defined for environments
<store> .Map </store> // For the store we use the K builtin Map
...
</mylang>
For the <k>
cell, I conclude that it is definitely only checked at start-up time, since program evaluation typically tears a program apart into an expression and a continuation (e.g. ADD ~> ...
) which cannot have the sort Pgm
anymore because ~>
is builtin.
So, elaborating on questions (1-2) above, is the <k>
cell exceptional in this sense?