“M” language model and infoof operator
If you are paying attention to “M” language specification, you will notice some very interesting additions in the latest draft, particularly if you are someone that likes to add the “meta” prefix to your words.
In short, DLan included the language model and the infoof operator in the spec.
The January CTP doesn’t do any of this yet, but the bits in our tree have had it for sometime and it should make it into the next CTP.
For those of you of a practical bent, this lets you do things like the below (how we would use something like this in our tooling is fairly obvious).
module Test { import Language.Catalog; type Person { Name : Text; Age : Integer; } People : Person*; Children() { People where Age < 18 } Documentation : { About : Language.Catalog.Declaration, Description : Text }*; Documentation { { About = infoof(Person).Declaration, Description = "Describes people" }, { About = infoof(People).Declaration, Description = "Contains people" }, { About = infoof(Children).Declaration, Description = "Extracts young people" }, } }
I don’t quite get it. (I know is supposed to be obvious). What does infoof do? Get the definition? (Info of?)
Shawn Wildermuth
20 Apr 09 at 00:39
infoof == info of.
the best analogy in the CLR world is typeof().
var type = typeof(Person);
That said, that is not quite right, but from a pragmatics standpoint, it works fine as an analogy.
In short, “M” now has reflection.
douglasp
20 Apr 09 at 01:30
Love the idea, but the operator name is horrible. As a non-native-english-speaker, I kept wondering what “infuf” was supposed to be. It is not very readable unless you’re familiar with it already (just mho).
Tomas Restrepo
20 Apr 09 at 02:50
Good feedback.
Open to new names.
In fact, Brad said that he had hoped we would change it prior to it getting in the bits.
Note that is not that same as typeof() or Identifier.class — as our data model is a good deal different.
douglasp
20 Apr 09 at 04:08
Why on earth would you seperate the documentation form the object within the same source document???
Either you would use inline documentation (like the documentation comments) or you would use external documentation. Not such a mixture…
My 2 cts
Marc Buzina
20 Apr 09 at 11:16
Hi,
same here. infooooof ist terrible. I don’t like camelcasing either. What about introducing “-”? info-of() or just info().
Lars
Lars Corneliussen
20 Apr 09 at 15:55
@Marc Buzina
This is an example, not some best practice.
Think typeinfo in COM.
We are looking at having “documentation” as a first class part of the catalog model.
You would likely populate this with “sugar” on the declarations in a source file.
BTW: there are no objects in our base model. You can, of course, model them.
douglasp
21 Apr 09 at 05:08
@All…
We are thinking of about(declaration) or declaration.about.
douglasp
21 Apr 09 at 05:09
What’s the current thinking on supporting multiple languages for the documentation? Considering that this information is going to be a source of documentation for an end user DSL, multi language support is going to be quite important.
Dody Gunawinata
21 Apr 09 at 09:41
re: `infoof`, FWIW Perl 6’s runtime meta-object accessors are:
WHO the package supporting the object, stringifies to long name
.WHERE the memory address of the object
.HOW the metaclass object: “Higher Order Workings” [ed. could be used for structually typed object systems]
.WHEN (reserved for events?)
.WHY (reserved for documentation?)
.WHENCE autovivification closure
.WHICH the object’s identity value
.WHAT the protoobject of the type, stringifies to short name ~ ‘()’
Matthew Wilson
21 Apr 09 at 16:54