'while/else' (ugh) (was Re: [oclug] Ruby)
Francis J. A. Pinteric
linuxdoctor at linux.ca
Fri Jun 27 20:04:19 EDT 2003
On 27 Jun 2003 19:43:54 -0400
Rod Giffin <rod at giffinscientific.com> wrote:
> On Fri, 2003-06-27 at 19:14, Francis J. A. Pinteric wrote:
> > On 27 Jun 2003 18:35:13 -0400
> > Rod Giffin <rod at giffinscientific.com> wrote:
> > >
> > > Remember this is an imaginary syntax for an imaginary language.
> >
> > It's not as speculative as you think ...
>
> :) Good! lol.
>
> > >
> > > I'm not talking about what you can do in C, or C++, Java or
> > > whatnot, I'm speculating about something new.
> > >
> >
> > In the speculative language under discussion, the code above the
> > above code would be written:
> >
> > while condition:
> > do some instructions
> > finally
> > do some stuff
> > end
>
>
> How does it tell if the while loop iterated? Wait a minute. The
> finally block could run whether or not the while runs, giving me a
> chance to catch a condition I didn't predict, can't it. So it becomes
> a bit like a try { } catch { } finally { } block in Java, only with
> the exception handling inside of the finally along side any cleanup
> code, instead of in a separate catch statement. What the heck, I
> could live with that.
>
> Rod.
>
It's got a long way to go, but here's an example from the Vega
interpreter itself:
Vega 0.0.1 (Fri Jun 27 15:31:41 EDT 2003)
[gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-110)]
>> x=0
>> while x<10:
>> print("Value is:" x)
>> x = x+1
>> finally
>> print("Done. x is:" x)
>> end
Value is: 0
Value is: 1
Value is: 2
Value is: 3
Value is: 4
Value is: 5
Value is: 6
Value is: 7
Value is: 8
Value is: 9
Done. x is: 10
>>
Constructs such as (x++) and the `for' loop hasn't been implemented
yet. The parser recognizes these things, but so far no code to make
them happen.
Right now, I'm looking at Ruby and seeing how close it is to what I was
thinking of doing with this thing. Why reinvent the wheel, right? It
takes quite a lot to implement a new language. Thanks the yacc, the
parser is a piece of cake, but all the other stuff still takes a lot of
code.
BTW. The language originally used `else' where the `finally' is in the
above code fragment. Thanks to David's suggestion, when I used
`finally' the several tables became smaller in size because shift/reduce
tables became smaller by about 30 elements each. Thanx David.
>>>--fja->
-- Fashion is for people who have no style.
There are three crimes which deserves the death penalty:
conformity, political correctness, and smoking.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://tux.oclug.on.ca/pipermail/oclug/attachments/20030627/9e662f19/attachment.bin
More information about the OCLUG
mailing list