>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"

The style of taking locales as the y parameter and returning a locale is pretty 
useful.  It also applies to pointers in my BN(openssl) and Arrayfire addons.  
It simplifies composition

2 (3 add add) tbl

A "hard" global current locale switch has problems with errors in that if a dsl 
is meant to be used interactively, an error can leave you in an unexpected 
locale.

verbs that take and return pointers or locales have the performance advantage 
that even though you normally want to see the side-effected "pretty printed 
data value" inside the pointer or object, when you 
just want to chain operations, you're not slowed down by the value extraction 
process.

Avoiding the from and to ideas also lets you use J methods on arrays of 
pointers and objects.





----- Original Message -----
From: Raul Miller <rauldmil...@gmail.com>
To: Programming forum <programm...@jsoftware.com>
Cc: 
Sent: Sunday, November 8, 2015 12:07 PM
Subject: Re: [Jprogramming] invoking object verbs without polluting global      
namespace

On Sat, Nov 7, 2015 at 9:07 PM, Joe Bogner <joebog...@gmail.com> 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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to