Ammonite Scale library

Dmitry Olshansky via Digitalmars-d digitalmars-d at puremagic.com
Sun Jan 18 08:09:28 PST 2015


On 18-Jan-2015 17:35, Tobias Pankrath wrote:
> What's up with that 'filename syntax?

If memory serves right it's Symbol in Scala which is about the same as 
string constant. The assumption is that compiler is aware of all symbols 
used in a program and keeps them interned at all times.
http://stackoverflow.com/questions/3554362/purpose-of-scalas-symbol
Differences are minor, I think the snippet tries to show that the 
library supports both.

I guess the code works by having an implicit conversion from String and 
Symbol to some PathSegment type from string and overloading / operator 
for PathSegments. Since there is no / for basic strings Scala as usual 
tries all implicit conversions of arguments to find the proper method.

All of this implicit conversion to some other type on demand may sound 
scary and is very much unlike D's way of extending existing types with 
UFCS. IMHO it's more powerful but more prone to abuse.


-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list