I just spent some time driving myself bats with the following code:
class Test
{
Void main()
{
quux := [Str:Bool][:]
echo "Size: $quux.size"
echo quux["foo"] // FLAMING DEATH!
}
}
Getting a compilation error on the // FLAMING DEATH! line above.
Why, oh WHY, should echo with a Str be legal, but echo with ANYTHING ELSE give a compilation error, unless its argument is in parentheses?
I mention this because I like fan's ruby-like relaxed attitude towards semicolons, and SOMETIMES parens... but please, if it can't do The Right Thing(TM) every time, please make them required everywhere. For now, that's how I'll have to treat it anyway.
brianSat 29 Aug 2009
Actually Fan always requires parens for method calls (unless there are no arguments).
But I just tried your code and sure enough echo works without parens for a string literal. I have absolutely no idea how that works, but it is a bug - it should be a compile time error.
brianSat 29 Aug 2009
Promoted to ticket #731 and assigned to brian
brianSat 29 Aug 2009
Renamed from Suggestion for Tour Intro to Method calls should always require parens
brianSat 29 Aug 2009
OK, I understand the problem now.
I am handling string interpolation in the tokenizer, not the parser.
So "size: $q.size" gets tokenized as ("size: " + q.size), which in turn gets parsed as the echo arguments with parens.
I will have to create a more sophisticated interface b/w the tokenizer and parser to handle this correctly.
tcolarSat 29 Aug 2009
LOL I've made use of this feature ---hu bug --- before :)
yachrisSat 29 Aug 2009
For whatever it's worth, I really like Ruby's "parens are not required... usually..." thing. It makes the code a lot more legible. Almost always... and when it's required, it's usually obvious (at least in hindsight). It's a similar feeling towards making semi-colons non-required. I just though, "Wow, I've been doing unnecessary work for a lazy computer all these years!"
I'm sure the parser is hell on wheels to get right, but since I don't have to write it, well, no problem :-)
qualidafialTue 8 Sep 2009
I will have to create a more sophisticated interface b/w the tokenizer and parser to handle this correctly.
Something like TokenVal.synthetic() : Bool? Looks like there is a method compiler::Tokenizer.makeVirtualToken used for string/URI interpolation, but it doesn't flag the token as synthetic.
yachris Sat 29 Aug 2009
Hello,
Please save some poor Rubyists' sanity :-)
I just spent some time driving myself bats with the following code:
Getting a compilation error on the
// FLAMING DEATH!
line above.Why, oh WHY, should
echo
with a Str be legal, butecho
with ANYTHING ELSE give a compilation error, unless its argument is in parentheses?I mention this because I like fan's ruby-like relaxed attitude towards semicolons, and SOMETIMES parens... but please, if it can't do The Right Thing(TM) every time, please make them required everywhere. For now, that's how I'll have to treat it anyway.
brian Sat 29 Aug 2009
Actually Fan always requires parens for method calls (unless there are no arguments).
But I just tried your code and sure enough echo works without parens for a string literal. I have absolutely no idea how that works, but it is a bug - it should be a compile time error.
brian Sat 29 Aug 2009
Promoted to ticket #731 and assigned to brian
brian Sat 29 Aug 2009
Renamed from Suggestion for Tour Intro to Method calls should always require parens
brian Sat 29 Aug 2009
OK, I understand the problem now.
I am handling string interpolation in the tokenizer, not the parser.
So "size: $q.size" gets tokenized as ("size: " + q.size), which in turn gets parsed as the echo arguments with parens.
I will have to create a more sophisticated interface b/w the tokenizer and parser to handle this correctly.
tcolar Sat 29 Aug 2009
LOL I've made use of this feature ---hu bug --- before :)
yachris Sat 29 Aug 2009
For whatever it's worth, I really like Ruby's "parens are not required... usually..." thing. It makes the code a lot more legible. Almost always... and when it's required, it's usually obvious (at least in hindsight). It's a similar feeling towards making semi-colons non-required. I just though, "Wow, I've been doing unnecessary work for a lazy computer all these years!"
I'm sure the parser is hell on wheels to get right, but since I don't have to write it, well, no problem :-)
qualidafial Tue 8 Sep 2009
Something like
TokenVal.synthetic() : Bool
? Looks like there is a method compiler::Tokenizer.makeVirtualToken used for string/URI interpolation, but it doesn't flag the token as synthetic.brian Sun 1 Nov 2009
also see #805
brian Thu 5 Nov 2009
Ticket resolved in 1.0.47
The tokenizer now generates a
lparenSynthetic
token instead of normallparen
to keep ambiguity out of the parser.