I've added a pure functional tacit version: http://code.jsoftware.com/wiki/User:Joe_Bogner/ByteCodeInterpreter#Tacit_Version
Here's a silly proof: NB. wrapped at 50 characters so line fees shouldn't cause issues run =: ; <;._2 (0 : 0) (0&{ , >:@:(1 {:: ]) ; 2&}.)@:(((1 {:: ]) { [) ((0 {:: ]) ; (1 {:: ]) ; {.@:(3 {:: ]) ; }.@:(3 {:: ] ))`((0 {:: ]) ; (1 {:: ]) ; '' ; <@:((0 { [) , 3 { :: ]))`]`(+/@:}.@:[ ((0 {:: ]) ; (1 {:: ]) ; '' ; <@:((0 { [) , 3 {:: ])) ])`([: (([: *@-~/ 2&({::)) ((0 {:: ]) ; (1 {:: ]) ; '' ; <@:((0 { [) , 3 {:: ])) ]) [: ([ ((0 {:: ]) ; (1 {:: ]) ; ((2 {:: ]) , 2 {:: [) ; 3 {:: ]) (0 {:: ]) ; (1 {:: ]) ; {.@: (3 {:: ]) ; }.@:(3 {:: ]))^:2 ])`((0 {:: ]) ; _ ; '' ; 3 {:: ])`]`]`([ (<@:(2&{."1@:(0 {:: ]) i. 6 , 1 {:: [) 1} ])^:(1 = 2 {:: ]) (0 {:: ]) ; (1 {:: ]) ; {.@:(3 {:: ]) ; }.@:(3 {:: ]))`(([: (0 0 $ 1! :2&2)@({"_)&(<;._1 '|exiting|greater than') 1&({:: )@:[) ] ])@.(0 {:: [) ])^:(1 = (1 {:: ]) < <:@:#@: [)^:_ (] ;&(0;'';'')) ) This program will add 6 and 5 together, pop the result into the current value register and then exit (; run) (128!:2) (3 6 5),(0 0 0),:(9 0 0) The resulting frame is the program, instruction pointer, current value, and stack (empty) +-----+-+--++ |3 6 5|2|11|| |0 0 0| | || |9 0 0| | || +-----+-+--++ Further demonstration of the power of J's tacit engine. A toy interpreter like this shows we can write code in an explicit mini-language and have it run tacitly. I'm not sure of practical uses and I'm not advocating using this for anything serious. J's tacit engine acts as a virtual machine for the byte code. On Tue, Nov 10, 2015 at 4:57 PM, 'Pascal Jasmin' via Programming <programm...@jsoftware.com> wrote: > J is arguably already bytecode... ascii. And fairly terse. > > an extension to this: > http://code.jsoftware.com/wiki/User:PascalJasmin/JON_assignment_free_pure_functional_DSL > > would be to use instead of an assignment system, an object that is a > combination of queue, stack and dictionary that stores and retrieves results. > > > > > ----- Original Message ----- > From: Joe Bogner <joebog...@gmail.com> > To: programm...@jsoftware.com > Cc: > Sent: Tuesday, November 10, 2015 4:49 PM > Subject: Re: [Jprogramming] essay: toy byte code interpreter > > Thanks. I don't have any application of it yet other than demystifying > the concept of a bytecode interpretation. It does open up some > interesting options of doing cool stuff with stacks in J. > > I am also thinking it would be a neat hack to implement a subset of J > in J using interpreted bytecode. I would then probably write an > interpreter of the bytecode in another language too for fun. > > > > > > On Tue, Nov 10, 2015 at 4:33 PM, 'Pascal Jasmin' via Programming > <programm...@jsoftware.com> wrote: >> Its cool. >> >> is your interest to do cool stuff with stacks in J, make a stack language or >> interpret bytecode? >> >> >> If its the first, I have many suggestions. >> >> >> ________________________________ >> From: Joe Bogner <joebog...@gmail.com> >> To: programm...@jsoftware.com >> Sent: Tuesday, November 10, 2015 4:07 PM >> Subject: [Jprogramming] essay: toy byte code interpreter >> >> >> I wrote this over lunch today and was pleased to see how simple it >> was. I'm posting here for those who don't follow Recent Changes. >> Feedback welcome >> >> http://code.jsoftware.com/wiki/User:Joe_Bogner/ByteCodeInterpreter >> >> I'd be interested in any speedups to the timing test that still permit >> jumps. It's fine as-is for a toy though >> ---------------------------------------------------------------------- >> 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