[Melbourne-pm] Arcane operators

Daniel Pittman daniel at rimspace.net
Mon May 10 01:43:03 PDT 2010

Toby Corkindale <toby.corkindale at strategicdata.com.au> writes:
> On 10/05/10 12:52, Daniel Pittman wrote:
>> Toby Wintermute<tjc at wintrmute.net>  writes:


>>> In Perl it seems like the received wisdom is to back away from writing
>>> code that looks like random line noise.
>> APL is pretty much the extreme end of the Domain Specific Language spectrum,
>> which is what operator overloading is a small step along the path to.
>> Done right, this still is gold: you can't beat it.  It is still the killer
>> advantage of Lisp, that it is so trivial to define a useful DSL, so you tend
>> to do it all along the way.
>> OTOH, done poorly DSL code is terrible.  Probably worse than, say, some of the
>> "I don't understand OO and find Perl5 scary" Perl that I get to support.
>>> If you could make up any operators you like, would you?
>> Yes, absolutely.  I also 'use overload' in Perl.
> So do I - but I'm overloading them within the original meaning.
> ie. + is adding or appending, - is reducing, " is making a printable response,
> etc..

...but the original meaning of '+' is never "appending" inside Perl, although
it is in some other languages; Perl has '.' for that purpose. :)

Arguably, some of these extensions, like '*', are quite reasonable: matrix
multiplication is well defined, and matrix calculus arguably extends some
functional bits into the array space, so...

In other words, I think "original meaning" is a weak definition, much like the
classic "I can't define indecency, but I know it when I see it" argument.
Potentially the best you can do, but not very solid — and easy for us to
disagree on. :)

> I am now tempted to create a library for Scala that entirely consists of
> smiley expressions, such as the sadface operator: a :( b
> the snowman operator: c ☃ d
> the wince operator: e >.< f
> the mind boggles operator: g o.O h
> and possibly the nethack operator:
> a ║..{.d.. at .]K### b
> hell, with enough custom operators, I could make a DSL for Nethack games.
> ? ( @ o.O @[Shopkeeper] ) { d => # }

I see a great need for a teco implementation in Scala. ;)


...I wonder if someone has ported A+ to it yet...
✣ Daniel Pittman            ✉ daniel at rimspace.net            ☎ +61 401 155 707
               ♽ made with 100 percent post-consumer electrons

More information about the Melbourne-pm mailing list