From: Rich Date: 2002-12-06T06:19:38+09:00 Subject: Re: [ANN] ratlast 0.1 -- embedded FORTH in Ruby Mark, I'm not nocking ya and I don't have a clue about FORTH... so... why would I use FORTH instead of Ruby? Where can I go to learn FORTH? -Rich ----- Original Message ----- From: "Mark Probert" To: "ruby-talk ML" Sent: Thursday, December 05, 2002 1:57 PM Subject: [ANN] ratlast 0.1 -- embedded FORTH in Ruby > > Rubyists, > > Later on today, I will be uploading the first release of > ratlast to RAA. You can get the system at > > http://www3.sympatico.ca/mark.probert/download/files/ratlast_0_1.tar.gz > > (This is my home account which I don't have access to at work. > I will upload the file around 19.00 EST.) > > > *** What is ratlast? > > ratlast is an extension gives Ruby the power and flexibility of FORTH, > using John Walker's ATLAST system. > > ATLAST is a F-83 style system that includes floating point > and string primitives, as well as systems FORTH standards such > as CREATE and DOES>. It is very powerful, flexible, fast, and > easy to extend. On the fly compiling is trivial. > > Most of all, it is a -lot- of fun to use! > > *** Example > > Here is a little magic :-). We create a linear equation ax+b and > give it the name 'linear'. For the example, we know the slope (3) > and intercept (17) and the x varies. We then evaluate the function > and print the result. > > (For the FORTHists in the audience, the stack is 4-bytes wide for > all integers, hence the 4 + ...) > > $ cat ex1.rb > require 'Atlast' > t = Atlast.new > > t.eval(": linear ( a b -- ) create swap , , does> dup >r @ * r> 4 + @ + ;") > t.eval("3 17 linear aline") > x = 1 > until x >= 10 > t.eval("#{x} aline .") > puts "x=#{x} : 3x + 17 = #{t.capture[0]}" > x += 1 > t.clear # clear the capture buffer > end > > *** Output > > $ ruby ex1.rb > x=1 : 3x + 17 = 20 > x=2 : 3x + 17 = 23 > x=3 : 3x + 17 = 26 > x=4 : 3x + 17 = 29 > x=5 : 3x + 17 = 32 > x=6 : 3x + 17 = 35 > x=7 : 3x + 17 = 38 > x=8 : 3x + 17 = 41 > x=9 : 3x + 17 = 44 > > > > -mark. > > >