Arc Forumnew | comments | leaders | submitlogin
Operator nomenclature
2 points by El_Indio 5708 days ago | 5 comments
While I understand and appreciate that for brevity's sake most operator's names are much shorter than their Common Lisp and Scheme counterparts I find that some changes are unnecessary or unnatural.

For instance the assignement operator '='. '<','>', '<=', '>=' are used for comparing numerical values but for numerical equalty 'is' is used instead of the more natural =.

Then there is 'def' for "define function" but 'mac' for "define macro".

Wouldn't it make much more sense to have 'fun' and 'mac' for functions and macros, 'def' or 'set' for assignement and '=' for numerical equalty?

Another one that's bothering me a bit is fn for lambda. Why not use something like 'ld' or 'lb'. Sure fn, which I assume is short for function, makes sense too, but what's wrong with lambda?



1 point by palsecam 5704 days ago | link

It's interesting to note that, but for the lambda point, at some time while playing w/ Arc, I also thought about the points you raise. So, since this is all about personal taste, here are my views. All of this is just my humble opinion.

About =. Well, yes, you can see '=' as the equality operator. Or, as I do, you can see it as "Arc copies the C style, where '=' is for assignation". So I thought well, if Arc copies C, let's use '==' for equality, instead of 'is'. But there are some problems with that. How do you name 'iso' and 'isa' then? The good point with the isx nomenclature is that it is coherent. One could use '===' for 'is and '==' for 'iso, but still, I can't think how to cope with 'isa using the '=' notation. And '===' is too long.

So finally, I'm OK with the '=' and the isx family.

About 'def and 'mac. Yes, yes, true, it's incoherent. 'def is a verb and 'mac is a name. But in a way, that's reflects that there is difference between a macro (definition) and a function (definition). After reflexion, I was ok with it.

About lambda. I prefer 'fn' over 'ld/lb'. In some other languages or even in Lisp code, when you want to refer to a function, you call it 'f' or 'fn' or the like. And everyone understands that. The meaning of 'ld' would not be evident. It means 'load' to me, at first look.

In the same "let's-not-abandon-the-lambda-terminology" vein, Haskell uses '\' to denote a lambda, imitating the glyph of the lambda character in the greek alphabet. I'd prefer that over 'ld/lb', but this is, IMO, a bit crappy anyway. I know many people, me the first, that couldn't understand what this '\' meant at first look. '\' is too much of a special char in the current computing world (basically: ask any programmer, he'll tell you it's the escape sequence). Since we don't live in a full UTF-8 world, and it'd not be usable to use the real 'λ' to denote an anonymous function in a source file, well don't try to badly copy this glyph. Plus, OK, '\' is shorter, but on my Azerty keyboard, and I suppose it's the same on a Qwerty, it's slower to type '\' than to type 'fn'.

And Clojure has also adopted the "fn" name.

Last but not least, in my view a programming language is actually close to a natural language, and well, natural languages for a lot of pratical/historical reasons are not that consistent/formal. People are not always, fanatically consistent. Think about it.

-----

1 point by El_Indio 5703 days ago | link

So you're saying is and isa are variations of isomorphic? I was actually thinking of the verb to be for 'is'. If that's true I agree it makes more sense. I still think '=' looks a bit awkward for prefix assignment though.

As for def and mac I think fun and mac would reflect the difference just as well as they stand for completely different words. ;) But anyway, for me it would be mainly about "freeing" def, so it could be used for assignment.

'\' for lambda is actually a very good idea. I agree that with lisps syntax it wouldn't be as clear as in Haskell though. Maybe another character with some resemblance to lambda could be used, such as 'h' or 'y'.

-----

1 point by palsecam 5703 days ago | link

There are 3 main "test" operators in Arc.

  arc> (= a 42
          b '(1 2 3)
          c "hello")
  arc> (is a 42)         ; test for equality, read as "_Is_ a equals to 42?"
  t
  arc> (isa a 'int)      ; test for type, read as "_Is_ 'a' _a_(n) integer?"
  t
  arc> (iso b '(1 2 3))  ; test for isomorphy ("same form" in greek), 'is doesn't work for lists (normal)
  t
  arc> (is c "hello")    ; "_is_ c equals to 'hello'?"
  t
  arc> (isa c 'string)   ; "_is_ c _a_ string?"
  t
So no, 'is and 'isa are not "variations" of isomorphic, but the names of 'is 'iso and 'isa are close because well, they are the same kind of things (test operators).

Yep, fun and mac are completely different words. I agree it could suffice. But 'fun would then be too close to 'fn (anonymous function/lambda) to replace 'def (define a function) IMO. Would prefer to change 'mac to 'defmac in this case.

About lambda: anyway what's the point with absolutely wanting to keep this word?! Church called his work "Lambda Calculus" because on the blackboard he used 'λ' because it's quick to write on a blackboard: two traits. But "lambda" is just an arbitrary name. I really don't see a reason to absolutely keep it when programming on a computer, where you can't quickly type "λ". Oh and "lambda" feels somewhat so pedantic.

Oh and all this is just cosmetic. Let's not debate about it for hours. We will never agree. De gustibus et coloribus non est disputandum (I sometimes like to be pedantic and use Latin :-P)

-----

2 points by conanite 5708 days ago | link

I notice I prefer euphonious names when I need to pick one even though I expect to talk arc rarely or never in conversation. It's probably easier to reason about variables when your brain doesn't have a side process figuring out how to pronounce them. I would run away from "ld" and "lb" for that reason. I would also prefer "fun" to "fn" because I bet there are psychological benefits from reading that word hundreds of times a day. Lots of fun. Could be a major selling point for arc.

-----

2 points by palsecam 5704 days ago | link

> Lots of fun. Could be a major selling point for arc.

Ah ah, I really laughed reading this. And jokes are to be taken... seriously :-D [1]

> I notice I prefer euphonious names

I respect your preference of course, but since we are in a "what's your personal opinion" thread, I'll give mine.

When I think about "fn" in my head it sounds "F-N", like the Unix `ls'/`cd' sound "L-S" / "C-D". I actually like these "saccatero sounds". In English, how do you pronounce "ISP" or "BTW" in conversation? Aren't people saying "bee-tee-double U" sometimes?

---

1: I'm serious here. I'd have probably never got into computers if it was not fun. I'm fond of the acronym jokes ("Gnu's not Unix", the names of the Lisp dialects Nil/T/Eine/Zwei, etc.). I'm in love with the fact my computer is full of daemons, indians (Apache), penguins and the like.

-----