Subject: Experiment - Quine
I was looking at Rosetta Code today and happened upon the Quine task, which inspired me to try to write one in ViviFire. I decided to use some features that I've considered but haven't yet implemented in the parser. If you all find this syntax agreeable, I'll probably add support in the next EXE release.
Code:
Dim a$()={"Dim a$()={","#null a$(0)+$34+a$(0)+$34+$44+$34+a$(1)+$34+$125+$NL+a$(1)+$NL"}
#null a$(0)+$34+a$(0)+$34+$44+$34+a$(1)+$34+$125+$NL+a$(1)+$NL

The features include:
  • Implicit dimensioning and initialization of arrays by using a list of elements inside curly braces
  • String constants by ASCII code/Unicode offset by preceding a number with a dollar sign, including all number bases (e.g. $42, $H2A, $O52, $B101010).
  • Similarly, string constants by (abbreviated) name, such as the $NL above which represents the platform-dependent newline character/sequence.

Semantically, the above code implies that the #Null object has a default method that sends a string to some output buffer such as stderr or a debugger's output window. I'm also considering naming this #Debug instead.

What do you think?

Subject: Re: Experiment - Quine
Brent,

These would all be great features!!

I would definitely change the #Null to #Debug though as I always think of the null character when I see something like #Null. #Debug would help to ensure that the user knows whatever comes afterward will be sent to an output of some kind. I assume you'll automatically detect if a (the) debugger is open and send it to that; otherwise I think you may need another variable to tell the language where the output is to be sent.

Just my thoughts on it....

{:0)

Brandon

Subject: Re: Experiment - Quine
I think that #null should be reserved to represent nothing or uninitialized.

#debug would be simple and understandable as triggering debug output.

Subject: Re: Experiment - Quine
Thanks for the comments. I just added support for the mentioned constructs. But then I discovered that my example has a syntax error.

The second line begins #null a$(0), which is parsed as a normal method call rather than the expected anonymous method call. After this, the parser expects a line break, but finds a + instead, causing the "oh so helpful" error -- line 2 col 12: this symbol not expected in Newline. I probably should do something about that.

The correct code follows.
Code:
Dim a$()={"Dim a$()={","#debug (a$(0)+$34+a$(0)+$34+$44+$34+a$(1)+$34+$125+$NL+a$(1)+$NL)"}
#debug (a$(0)+$34+a$(0)+$34+$44+$34+a$(1)+$34+$125+$NL+a$(1)+$NL)

Subject: Re: Experiment - Quine
What I still see as strange is the missing closing curly brace in the first line of code.
If this is the supported syntax, it is fully on the contrary to what one is used from other languages utilizing curly braces.

Subject: Re: Experiment - Quine
Stefan, the closing curly brace is represented by $125 which translates into LB as Chr$(125). The second line cannot contain any quotes, otherwise they'd need to be escaped in the first line. This makes the code simpler.


Page 1 of 1


Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum

Full Version
Powered by phpBB © phpBB Group
Design by phpBBXS.Com | Lo-Fi Mod.