Well, my plan, which I've largely succeeded in implementing is a demonstration application that is written in C/C++ and hooks in to J by libj.so. This may not be very interesting for hardened J veterans, but for beginners it may be interesting, especially for anyone wondering if J can be used for game development in any way, to which the answer seems to be a resounding yes, kind of, maybe. Also, it may be of interest to beginners who just wonder how to use libj / j.dll, which is not the easiest thing to figure out.
I developed a demo puzzle game app (using the SDL library) that does pretty much all the logic in J. https://github.com/jonghough/CPP2J_Demo The game itself is pretty simple and uninteresting, but it's just a demo to see what CAN be done with J. When I was writing it I didn't realize we could feed in entire scripts into libj.so, so I might refactor it later to do that. As an aside, rather than doing it the way I did, it would be good if there was a J wrapper for SDL (see pygame for the python wrapper), but it seems to implement that there needs to be a J interface to SWIG, which I don't think exists, and building one is outside my knowledge of J and C++. Regards,Jon > From: [email protected] > Date: Sat, 4 Jul 2015 22:05:13 -0400 > To: [email protected] > Subject: Re: [Jprogramming] Feeding multiline verb definitions into JDo > > The API reference doesn't mention the ability to execute a script > since that is a property of the language, and not the api reference > itself. > > So it winds up being (after you have got the session running) a jset > followed by a jdo. > > A trick, though, is that you'll have to use language features (13!:) > to support debugging of the code within your application. So that'll > be something like jdo("13!:0]1"); to enable debugging, jdo("13!:1''"); > to get a readable stack trace, and so on... > > Good luck, > > -- > Raul > > On Sat, Jul 4, 2015 at 9:57 PM, Jon Hough <[email protected]> wrote: > > Oh, we can execute an entire script? I did not know that. If this works it > > could make things ... interesting. > > Incidentally, the API reference, which is surprisingly tricky to track > > down(I found a version here: > > http://www.jsoftware.com/pipermail/programming/2013-June/032979.html ) > > does not seem to mention this. I know there is a j.dll reference somewhere > > in the wiki, but my searches come up with nothing. (I think j6 also has > > some j.dll reference *.ijs scripts, perhaps I should install it). > > Anyway, thanks, I will give this a try. > > > >> From: [email protected] > >> Date: Sat, 4 Jul 2015 21:49:11 -0400 > >> To: [email protected] > >> Subject: Re: [Jprogramming] Feeding multiline verb definitions into JDo > >> > >> It has been a while since I have attempted any such thing, but you can > >> also define variables which contain arbitrary text (such as a script), > >> and you can execute them using the 0!: family of foreigns. > >> > >> JDo('0!:110 script'); > >> > >> That said, note that your biggest issue, when you get to deploying the > >> software you develop, will be isolating errors experienced by your > >> users. Assuming you wrote decent code, these will typically externally > >> induced. > >> > >> So you might want an option to use 0!:111 or some such? It'll be worth > >> going through a few induced errors (permission denied on a file > >> reference, for example) *after* you have things working, but before > >> you release the code. > >> > >> Thanks, > >> > >> -- > >> Raul > >> > >> > >> On Sat, Jul 4, 2015 at 9:42 PM, Jon Hough <[email protected]> wrote: > >> > It seems that when using the j.dll (libj.do) API from another language, > >> > JDo allows the defining of verbs. But I have only managed to define > >> > single line verbs so far. It seems adding LF or even '\n' into the > >> > command string parameter of JDo does not work (in the sense that it will > >> > return an error when using JGetM). > >> > Does anyone know if it is possible to do multiline definitions, and if > >> > so how? > >> > Thanks,Jon > >> > ---------------------------------------------------------------------- > >> > For information about J forums see http://www.jsoftware.com/forums.htm > >> ---------------------------------------------------------------------- > >> For information about J forums see http://www.jsoftware.com/forums.htm > > > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
