Assuming your mean internal DSLs: No and almost certainly no.
The parser support in the Scala standard library handles external DSLs
well.
Randall Schulz
Why is there no plan to support precedence in user-defined operators? At the moment, it seems that all such operators have the same precedence.
Parens? Usually works for me.
Imagine we could alter precedence and you read this line:
val x = foo + bar * baz
how would I visually interpret the line in the presence of alterable
operator precedence?
Just asking. I can actually see the argument going both ways. In the
end the compiler writers get to decide.
--
Jim Powers
Maybe I am misinterpreting your question, but user-defined operators (well, functions...)
do have precedence:
Scala Reference 6.12.3:
<<
An infix operator can be an arbitrary identifier. Infix operators have precedence and
associativity defined as follows:
The precedence of an infix operator is determined by the operator’s first character.
Characters are listed below in increasing order of precedence, with characters on the same
line having the same precedence.
(all letters)
|
^
&
< >
= !
:
+ -
* / %
(all other special characters)
That is, operators starting with a letter have lowest precedence, followed by operators
starting with ‘|’, etc.
>>
and more in the ref.
The nice advantage of this approach is that classical numerical operators keep their
precedence, and custom operators have precedence in a familiar (I agree with Jim here)
way. It is similar in C++ (where you can only overload existing operators): whatever the
meaning assigned to them, they keep their precedence. Overloaded operators can be
confusing (often less readable than functions, ie. words, if you don't know the doc),
altering precedences would bring even more confusion! ;-)
And it is elegant: I wonder how you would define precedences otherwise? Using a numerical
value with a special notation? Using a special expression ordering the operators in a
relative way?
--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --
--
Tony Morris
http://tmorris.net/
I understood and I show you can define precedence for your operators... as long as you
stick to Ascii (at least for the first char).
Indeed, if you use Unicode dingbats ;-) for operators, you have to rely on parentheses.
Not necessarily a bad thing, not sure if it is obvious that ※ has a higher precedence than
⁂ unless you are very familiar with the API.
BTW, these symbols can be nice for mathematical-oriented APIs, but can be a nightmare for
the poor programmer having to copy/paste them or or to use IDEs to exploit the API (or to
use textual aliases, but loosing the advantage of symbolic notation then).
* The core API of VTD-XML has been expanded. Users can now perform
cut/paste/insert on an empty element.
* This release also adds the support of deeper location cache support for
parsing and indexing. This feature is useful for application performance
tuning for
processing various XML documents.
* The java version also added support for processing zip and gzip files.
Direct processing of httpURL based XML is enhanced.
* Extended Java version now support Iso-8859-10~16 encoding.
* A full featured C++ port is released.
* C version of VTD-XML now make use of thread local storage to achieve
thread safety for multi-threaded application.
* There are also a number of bugs fixed. Special thanks to Jozef Aerts, John
Sillers, Chris Tornau and a number of other users for input and suggestions