Closed titanseason closed 7 years ago
yes! :))) I just try to find small english word that would serve as concatenation... any ideas?
ql()
sql()
add()
I believe sql
make most sense as it is raw sql. wdyt?
Out of that list I'd vote for add()
.
However (and there is always a but, isnt there ;-) ) _()
is a convenience method for append()
and with two very similarly named methods (add/append) doing the identical thing it might become eventually confusing/redundant. As those aliases/shortcuts should usually be as short a possible, the dollar sign (as used in Jerry too) might be a good solution.
Alternatively - and not without potential drawbacks - a Unicode character such as fullwidth low line (_
) might be an option (Java unfortunately does not accept fullwidth plus (+
)). Of course that could create typing - though autocomplete might come to rescue here - and display issues, apart from confused users. I wanted to have it mentioned though :).
Good catch @neroux , I forgot there is append
which does the same :) In that sense, having another shorter-named method that does the same is... meh :) Then maybe We can simply have one method and not the shortcut (i.e. append
-> add
).
Wow, unicode character!!! This is mindblowing @neroux!!! Reminds me to:
double Δt = lastPollTime - pollTime;
double α = 1 - Math.exp(-Δt / τ);
average += α * (x - average);
I took _
because its visually small and this append
/add
is used a lot, so its much cleaner to read. But you are absolutely right; the shortcut must be as short as possible, hence proposal is:
append
to add
(its shorter)int _, ‿, ⁀, ⁔, ︳, ︴, ﹍, ﹎, ﹏, _;
Moreover: the following
for (int i = Character.MIN_CODE_POINT; i <= Character.MAX_CODE_POINT; i++)
if (Character.isJavaIdentifierStart(i) && !Character.isAlphabetic(i))
System.out.print((char) i + " ");
}
prints
$ _ ¢ £ ¤ ¥ ؋ ৲ ৳ ৻ ૱ ௹ ฿ ៛ ‿ ⁀ ⁔ ₠ ₡ ₢ ₣ ₤ ₥ ₦ ₧ ₨ ₩ ₪ ₫ € ₭ ₮ ₯ ₰ ₱ ₲ ₳ ₴ ₵ ₶ ₷ ₸ ₹ ꠸ ﷼ ︳ ︴ ﹍ ﹎ ﹏ ﹩ $ _ ¢ £ ¥ ₩
Now thinking, _
will be probably used in some future version of Java, similar like it is used e.g. in Go language; so having anything similar might not be good idea....
At the moment they do not seem to have big plans for the underscore -> http://git.net/ml/lambda-development-java/2013-07/msg00350.html however yes, the fullwidth low line is visually almost identical to the underscore and that might raise some confusion.
What would you think about $
? Its short (even by actual byte count), a popular alias, already used by Jerry, and according to http://mail.openjdk.java.net/pipermail/lambda-dev/2013-August/010676.html safe to use (until they change their mind ;) ).
The issue with $
might be that it is used inside of these sql templates a lot. So you might have something like:
...$(" and $table.id=")...
which might be kind of confusion as well, right?
I understand what you mean. I guess in some cases it could confuse some people but generally I'd assume it should be clear what is a command and what data, particularly with syntax highlighting.
My main concern with Unicode characters is about their "typeability" (though that might mitigated by aforementioned autocomplete) and possibly encoding issues.
hey man, you are right!
in fact, i just realized that example i gave above can't happens. so $
might be nice shortcut.
The template is where $
appears, and those two can't never happen together.
For Jerry it ways easy, since this is what JQuery is using ;) Cool!
Just in time :). With Java 1.9 (currently due in July) _ does not yield a warning anymore but straightforward an error
https://blogs.oracle.com/sundararajan/entry/underscore_is_a_keyword_in
Awesome!!!
When I use
DbSqlBuilder._()
method, Eclipse (J2EE) tells me'_' should not be used as an identifier, since it is a reserved keyword from source level 1.8 on
.Any plan to change this method name?