Closed benpate closed 3 years ago
I wonder if we should drop &&
and just go w/ what hypertalk did
The trouble here is that &&
is so common to most modern developers that its second nature to use. You'll have tons of cleanup to do even in the hyperscript examples.
But, I can't imagine anyone is already using &&
with strings, so it seems like it should be safe to overload this operator.
People definitely use && with strings.
if (options.prefix && options.selector) {
// check the existence of prefix and selector, which are both strings
}
That's a fantastic example, @dz4k. It would require a small change to make your code above work correctly. If we adopted this syntax for string concatenation, you'd have to say if options.prefix and options.selector then...
instead.
I think this is a cool idea, but it would only work if we're okay with removing (or confusing) support for the javascript &&
operator. I'll leave that decision for the big boss, but my first thought is that it may not be worth the confusion.
http://rigaux.org/language-study/syntax-across-languages.html#StrngStrnCnct
AFAIK ^
isn't used for anything as of now.
P.S. Is this really necessary when template literals exist?
True. It's probably more trouble than it's worth. Let's just close it :)
The original HyperTalk used
&
for string concatenation, and&&
for string concatenation with a space in between. This would be really useful, and would help avoid statements like thisset fullName to firstName + " " + lastName
-- changing them into this insteadset fullName to firstName && lastName
Right now, hyperscript uses
&&
as a logical AND operator, and we should not change this. But, would it be possible (and not too confusing) to overload this behavior when dealing with two strings? Or, would it be better to use a different operator for this?