[erlang-questions] I think I wish I could write case Any of whatever -> _ end.

Henning Diedrich <>
Tue May 18 05:05:05 CEST 2010


Richard, righteous,

I was just curious about the defense you'd mount to keep ~ for the frame 
syntax.

Where the first thing that hit my uneducated I was how the use of ~ in 
it was so completely special --- as some other symbol uses in Erlang are 
--- that it, well, may be an excellent fit. Why starting to get 
conventional. A language proudly flying =< could also have ~ to mean 
'something like' while really, yes, significantly different from =.

I think I already got used to the proposed frame syntax, followed your 
arguments and support it.

But I think ~ would be great to also roughly mean 'what I just said'. 
Also ./. might do, or -"-, or *.

The argument about being hard to pronounce sounds a bit convenient in 
this context. Pronouncing code is a rarified art and runs into this 
problem time again. There'll be a suggested way to say it and then that 
is that. Some suggestions below. Or was the pronunciation of frame 
definitions already decided upon?

I think 'sorta-kinda' for ~, as you proposed, may be just fine. It has 
this ring of order to it (sort-a), and of being nice (kind), which will 
help it be easily remembered. Things like this count! Plus, it will also 
work for frame definitions where you pointed out that 'equals' would be 
awfully wrong.

But just as '=' can mean many things to different people, maybe '~' can 
be used for both things.

I thought it was a tad illogical, however, to argue that because there 
is no obviousness to the meaning of <<< in Lisp might indicate that the 
'some as above/before' connotation of ~ should likewise and somehow 
guilty by association be irrelevant or even counterproductive when 
deciding about. It's use.

Not that I believe that anyone cares, but eye have a hobby horse that 
had me thinking about hacking the pre-compiler already: the doubling of 
function signatures where the variation that is /called/ in the former 
is, plus one default argument as literal, exactly the head of the next. 
I might be doing something wrong there but I keep copying heads and it 
makes the code hard to read. I regularily go, copy a head, paste it 
three times (one over the old ) and alter two of them marginally. A nice 
remedy could be:

Fun(A) -> Fun(A, b).

Fun(A,B) ...

This could become

Fun(A) -> ~~ b.

Fun(A,B) ...


Where ~~ would mean, 'the thing I just wrote, in and out of the 
brackets, and add this parameter as last argument'.

It could be pronounced 'same-but-with' or 'razor', because that's really 
what it does, razor some boilerplate and double expressiveness, no? It 
could not be used every time, but could clean up some code.

~~~ (3x) finally, could be used to be expanded internally into _ -> ~, 
or, X -> X and could be called 'tri-barbed-wire' as I think you 
suggested. I can pronounce that.

Sorry there is no relation to the negation connotation that ~ somehow 
brings along. But that seemed to be alright for its use in io:format in 
the first place, didn't it? Also, somehow, it negates writing code doubly.

Yours sincerely,
Henning


Richard O'Keefe wrote:
>
> On May 18, 2010, at 12:01 PM, Henning Diedrich wrote:
>
>> But if it was another symbol? Say ~.
>
> No, let's NOT say \sim, a symbol widely used in mathematics and
> physics for something that is syntactically a binary relation
> and means "sort-of equal, kinda", which is why I want it for
> frames, and is used in a variety of programming languages as a
> unary operator with negation-related meanings.
>
> But what if it were some other symbol?
> Well, WHY a symbol?  What's the difference between @#$%^ and Fred?
> The differences are clear:
>
>   + there is an infinite set of variable names, which can be
>     chosen to be easy to pronounce and understand, allowing you
>     to name many things at the same time
>
>   - a symbol is one thing, probably doesn't have an agreed way
>     to say it (is ~ "tilde", "wiggle", "squiggle", "sim",
>     "roughly equals", or what) and has no special connexion with
>     what it stands for; since there's one of it, it's very hard to
>     use in a nested context.
>
> Example:  Common Lisp has
>     * the value of the last expression you typed in
>     ** the old value of *
>     *** the old value of **
> What happens if you want to refer to the old value of *** ?
> Tough luck.  What happens if you miscount and typed ** when
> you meant *** ?  Tough luck.  What is the connection between
> multiplication and history that makes this memorable?
> There isn't one.
>
> (OK: + ++ +++ are the last three forms you typed,
>  * ** *** are their (primary) values
>  / // /// are the lists of all their values
>  - is the form that is being evaluated right now
>  How "-" gets to be more recent than "+" is a mystery,
>  but at least they managed to blow this up into an
>  "arithmetic function = history variable" analogy.
>  The consistency is perfect.  < << and <<< do the
>  obvious things.  No, wait, there _is_ no obvious
>  thing, and if there were, they don't.  Oh well,
>  at least there are consistently X, XX, and XXX versions.
>  No, wait, there aren't.  -- and --- do not exist.)
>
>
> Why invent triangular wheels covered in barbed wire and razor blades
> when we have nice round rubber ones?
>
>
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:
>
>


More information about the erlang-questions mailing list