"I am not in Rome." | ||
-- An anonymous designer of his own DOS 8086 Assembly written in itself, and used to write other programs, in which numbers that start with 0 are hexadecimal. |
I encountered some Scheme implementations in which identifiers were case-sensitive, and some in which they were case-insensitive. To match what is the norm nowadays, and because I like it better, Park requires case-sensitive identifiers.
Numbers in Park can be decimal, octal (if they start with "0"), or hexadecimal (if they start with 0x). Following Perl's lead, one will be able to use underscores (_
) within numbers (e.g: 100_000
instead of 100000
).
String constants will be written in a large correspondence to the C, Perl 5 and Perl 6 conventions. For example, a "\n" will designate a newline. The exact type and quoting of the string will be determined by a few optional Perl 6-like modifiers. Here are a few examples:
# The (qq ... ) is not really needed but it doesn't hurt. (my mystring (qq "Hello there, Hackers! Welcome to Park")) (print mystring "\n") (my regex (m :p5 "H..kers")) (say (=~ mystring regex)) # Prints "Hackers" (my conv (tr "H" "B")) (say (=~ mystring conv)) # Prints "Bello there, Backers!..." (my newstring mystring) (=~! newstring conv) # newstring is now "Bello there, Backers!..." # (You gotta love S-expressions.)
There was a very interesting presentation in an Israeli Perl Mongers meeting about strings, quoting and interpolation in other languages and Perl. The presentation noted among else that in other languages one has to write relatively ugly code like "Hello" & Name & "! What's up?"
rather than the Perl "Hello $Name! What's up?"
.
In Perl 5 the interpreter has some heuristics for determining the end of the interpolated expression, which can be any arbitrary Perl expression. Perl 6 goes one step further and parses the string and translates it into Perl 6 code, so one can safely include arbitrarily complex code there. (In a similar fashion to the Korn shell "$(...)" construct).
What I plan is to have such interpolation in Park as well for some types of strings. The syntax will look something like that:
(my i 5 j 7) (print "${i} + ${j} = $(+ i j)\n")
As expected this prints "5 + 7 = 12" (followed by a newline).
Another thing I'd like to have is shell or Perl 5-like here documents (&&"EOF" ... EOF
)