On Sat, Nov 7, 2015 at 9:07 PM, Joe Bogner <[email protected]> wrote: > I'm playing with the idea of a domain specific language against a > object that will have a fair amount of state. > > The syntax will be something like > > 4 add 2 add to tbl > > or ideally > > add 4 add 2 to tbl > > I think the latter will have difficulty implementing but would be > preferred if possible. > > There will be many verbs in the dsl (maybe 10-15). > > Below is a proof of concept that works fine. I think using the 'to' to > set a global to the current locale is kind of hacky, but I can live > with that. > > My bigger concern is making each of the table methods public in the z > locale. Is there a way to dispatch them to the table/CURRENT locale > without making clobbering other verbs in the z/base locale? My > research suggests the answer is no, but was interested in any clever > solutions. I'd also like to avoid adding many more keywords (such as > modifier to intercept the call and convert it) > > Alternatively, I considered passing a string of the dsl and chopping > it apart and interpreting it, but I liked the idea of avoiding the > string argument if possible.
Hmm... My thoughts were: (1) The : 0 phrases (for example: explicit definitions) are already about passing strings, chopping them apart and interpreting them. (2) The cocurrent verb (or, more specifically, 18!:4) is aimed at a problem specification very like what you are suggesting here. (And, I see that Pascal has already suggested something similar.) (3) Nouns, on the other hand, do not know which locale they live in - they are meant to be the messages passed between locales. It would be best, I think, if you paired up "to" on the right of the sentence with a word on the left of the sentence which terminates the dsl expression. My verbal imagination fails me at the moment, so I'm going to use "from". With this, tbl could be a locale reference, and - 'to' would switch to the locale and return its left argument. 'from' would switch you back to 'base' locale and return a reference to tbl's locale. (You could get fancy and maintain a locale call stack, but that gets you into guarding against stack imbalances - easier to just say that mixing dsls should happen in different explicit verbs, or with great care.) Thanks, -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
