Re:Why Dart is not the language of the future.
by andrewcooke on Tuesday October 11, 2011 @12:29PM
(#3099203)
please can you explain what
value = 5 "The value is " + 5
is supposed to do? at the moment i can't work out why it would be frustrating to be unable to type something that looks like a syntax error... (i'm assuming it has some meaning in a language i don't know, which i guess would mean php).edit: what does "say" mean in the reply below? print? evaluate? and does "later" mean in another statement? or replacing what was before?
Re:Why Dart is not the language of the future.
by stickfigure on Tuesday October 11, 2011 @01:45PM
(#3099536)
The problem is that his two lines of code got joined by HN's formatter (which needs two newlines for a real line break). Presumably his desired message was:
value = 5
"The value is " + 5
Re:Why Dart is not the language of the future.
by Miky on Tuesday October 11, 2011 @12:40PM
(#3099255)
He means that he can't say “value = 5” and then later say “"the value is " + 5”.
Re:Why Dart is not the language of the future.
by phaedryx on Tuesday October 11, 2011 @12:40PM
(#3099256)
I see that as a feature. It looks like you're saying "I want to add numbers and letters together and Ruby complains."
If you really want that value in your string, why not use "The value is #{value}"
Re:Why Dart is not the language of the future.
by andos on Tuesday October 11, 2011 @12:56PM
(#3099330)
Maybe they're afraid the translation team will be overly grateful?
Re:Why Dart is not the language of the future.
by paragraft on Wednesday October 12, 2011 @03:09AM
(#3101835)
Appending doesn't work for translation: not all languages will have the object at the end of the sentence. Better to stick with format strings.
Re:Why Dart is not the language of the future.
by andos on Thursday October 13, 2011 @08:49PM
(#3109455)
That's what I meant...
Re:Why Dart is not the language of the future.
by msy on Tuesday October 11, 2011 @12:22PM
(#3099177)
Just use inline implicit conversion: "r #{5+3/2}"
Re:Why Dart is not the language of the future.
by jamesbritt on Tuesday October 11, 2011 @04:09PM
(#3100102)
It's a lot more typing. :)
If one really wanted that kind of behavior (and not getting errors when trying to add strings and number) you could make it so:
class String
def +(o)
warn "You are adding a #{o.class} to a string." unless o.is_a? String
"#{self}#{o}"
end
end
for example.Whether this leads to other issues is left as an exercise for the reader and whomever ends up maintaining the reader's code.
Re:Why Dart is not the language of the future.
by rat on Wednesday October 12, 2011 @04:03AM
(#3101951)
"r#{5}"
or in actual use something like "I have #{me.num_of_children}\n"
much better then Auto conversion
In python "I have " + str(me.num_of_sons) + "and " + str(me.num_of_daughters) +"\n"
does get annoying
>Ok. This is a good thing. Auto conversion is bad.
One of the things I really dislike about developing in Ruby is that I can't do
value = 5 "The value is " + 5
I get bitten by this at least 10 times a day while developing, usually either when dumping to the log, or writing into html. I can fix the problem really quickly now, but every time I get an error:
"r" + 5 "TypeError: can't convert Fixnum into String"
I think, yes, yes you can easily convert a Fixnum into a String.
"r" + 5.to_s
It just means I have to sprinkle .to_s everywhere in my code. Ridiculous!