[Melbourne-pm] Arcane operators

Toby Wintermute tjc at wintrmute.net
Sun May 9 19:03:17 PDT 2010

Just something I felt like passing along..

I've been playing with Scala every now and then, as I've mentioned before.
It has some nice advantages, like a great concurrency system, a good
OO implementation, and it's quite fast once the jvm gets warmed up.)

I've noticed a worrying trend in Scala libraries though.
In Scala you can invent your own operators - they're just functions on
the objects with those names. And it seems that Unicode is valid too.
In a couple of actually-popular libraries I have seen the following
operators. I had to copy-and-paste some of them because I don't know
the right X Compose sequence to input them!

1) /:  (was used to create a URL object from a string)
2) #::   (I couldn't work out what this did from the context)
3) >:>   (Described as "Process Header as map in block")
4) ∘   (Couldn't work out what this did from context either)
5) ↦   (Also unsure.)
6) >|   (Described as "Ignore response body")

There are some cases where symbols seem to work well, such as:
my_list_of_things.each( thing => { doSomething(thing) or
somethingElse(thing) } )
or to build a map:
var userIDs = Map(1 -> "root", 2 -> "daemon", 5 -> "games", 8 ->
"mail", 9 -> "news")

but for the most part, it feels like it's going a bit crazy.
In Perl it seems like the received wisdom is to back away from writing
code that looks like random line noise.

If you could make up any operators you like, would you? Do you think
it improves code readability or makes it worse?


Turning and turning in the widening gyre
The falcon cannot hear the falconer
Things fall apart; the center cannot hold
Mere anarchy is loosed upon the world

More information about the Melbourne-pm mailing list