8

I have read an article by Jonathan Worthington about meta programming. There he writes:

Do do this, we stick it in the EXPORTHOW module, under the name “class”. The importer pays special attention to this module, if it exists.

At he same time here Jonathan uses DECLARE. Is there any documentation about that and other similar things? What and when should one use? What are other special things importer looks for?

I tried to search the official docs but failed to find anything there.

Thank you in advance!

hasrthur
  • 1,410
  • 15
  • 31
  • 2
    I'm afraid not. All the metamodel is underdocumented. In this case, `DECLARE` is used to kinda create new syntax when exporting, instead of just exporting the name of the class. – jjmerelo Jan 28 '22 at 18:49
  • where can we at least look at all possible things like that? – hasrthur Jan 28 '22 at 22:42
  • 1
    See also [jnthn's answer to SO Q **Using `EXPORTHOW` to make declarator that acts like "sub"**](https://stackoverflow.com/a/70342023/1077672). – raiph Feb 01 '22 at 00:32

1 Answers1

4

where can we at least look at all possible things like that?

Aiui the source code of the Rakudo compiler is as good as you're gonna get.

It looks to me like EXPORTHOW is processed here, with DECLARE in particular here, as part of World.nqp.

Afaik the World class is:

  • An internal implementation specific detail of Rakudo. It is not part of the Raku language. It is not something you can rely on. It is not officially supported.

  • Written in nqp. nqp is not Raku. It's essentially a small subset of Raku focused on being a good programming language for writing compilers.

raiph
  • 31,607
  • 3
  • 62
  • 111
  • thank you for that! as far as I can see EXPORTHOW might also have SUPERSEDE and COMPOSE keys. Do You happen to know what they do as well? – hasrthur Jan 30 '22 at 15:35
  • 2
    No. First, please know that what I did for my answer was to fire off [a search within the compiler source code for `EXPORTHOW`](https://github.com/rakudo/rakudo/search?p=3&q=exporthow), skim the list of matches, click on likely prospects, search for `DECLARE` in each, and settle on providing the two `World` links. For `COMPOSE` I see `NYI('EXPORTHOW::COMPOSE')` and know `NYI` will mean "Not Yet Implemented". [A search for `SUPERSEDE`](https://github.com/rakudo/rakudo/search?q=supersede) shows an `.NYI` for that too, and the `Exception` match suggests it's for overriding an existing declarator. – raiph Jan 30 '22 at 22:00
  • 3
    Please note that `World.nqp` does not exist in the RakuAST branch, which will become the main branch of Rakudo this year. All of its logic will be incorporated into RakuAST classes. So learn from the concepts in `World.nqp`, not from the code! :-) – Elizabeth Mattijsen Jan 31 '22 at 11:04