Arc Forumnew | comments | leaders | submitlogin
[... _ ...] is fishy
7 points by ryszard_szopa 6141 days ago | 15 comments
The [... _ ...] macro exhibits a pretty unexpected behavior. For example:

arc> ([_ 1 2] +)

3

arc> (mac _ (x y) `(* ,x ,y))

#3(tagged mac #<procedure>)

arc> ([_ 1 2] +)

2

This may lead to quite horrible bugs, specially w/o a package system. Just imagine a library setting `_' to something that would _sometimes_ behave correctly. Finding what was wrong would be a nightmare.

A possible solution would be to somehow restrict assignment to _ outside of the brackets macro... Or making it unbound it at the beginning of the brackets macro... However, this would break the "let the programmer do what he or she wants" maxim...



9 points by Zak 6141 days ago | link

Imagine a Ruby library redefining what + does for numbers. Globally redefining the syntax of the language is almost certainly a mistake unless you're developing a new language. Of course, you might want to design a new language by redefining the built-in functions and macros of Arc.

Redefining _ introduces horrible bugs? Don't do that then.

-----

3 points by connellybarnes 6140 days ago | link

Why would I want to partake in a system that doesn't let me do what I want? Down that path lies Java, corporations, government, masses of idiotic consumers, debt, busywork, social pressures to be fat, stupid, and drink until both of these occur, character sets, funding the so-called "poor" in America so that they can shoot each other and do more drugs, funding the police to shoot the poor when they do drugs, social badges, displays of wealth, and a lifetime of wage slavery to help further enstupify an already mindless culture made thus by money and gadget fetishization. Oh wait, we've already followed that path. Oh, brilliant.

-----

1 point by kennytilton 6140 days ago | link

Given the stated philosophy of (er, paraphrasing) doing the fun stuff first, I think bullet-proof footwear is one of the last things to look for at this juncture.

-----

3 points by cje 6141 days ago | link

Another possibility is to have the bracket's reader-macro stick in a gensym, so

[_ 1 2]

becomes

(fn (_g12) (_g12 1 2))

Of course, until we have real gensyms, this just makes screwing it up a bit harder.

-----

5 points by randallsquared 6141 days ago | link

Arc has gensyms, using uniq. Or am I missing your meaning?

-----

1 point by cje 6141 days ago | link

Gensyms yes, but they're actually interned symbols of the form "gs231". See arc0/ac.scm:641. "currently rather a joke"

-----

2 points by randallsquared 6141 days ago | link

That's an implementation detail. ;)

-----

1 point by tokipin 6140 days ago | link

  ([_ 1 2] +)
i haven't used lisp much, but that example is awesome

-----

1 point by scav 6139 days ago | link

Seconded. As soon as I saw the [+ _ 1] example I wondered - can you put the _ anywhere? Yeah, apparently so.

I love it when I see a new programming notation and really, really want to play with it.

-----

1 point by tlrobinson 6141 days ago | link

Or just say "_" is reserved in Arc?

-----

3 points by lg 6141 days ago | link

Seems like the Arc-philosophy-response would be, let 'em redefine _ if they want to. And that philosophy will probably make me want to murder somebody one day.

-----

3 points by Zak 6141 days ago | link

Ferraris don't come with speed governors.

-----

3 points by ryszard_szopa 6141 days ago | link

Driving a Ferrari is rarely a collaborative endeavor :-)

Keeping `_' safe in fact increases the programmer's freedom. If I knew that by doing something I was going to fk up w/ other people's code and how they expect their code to behave, I would rather not* do it. OTOH, if there are namespaces, etc. then I know that I can enforce whatever coding conventions I want, in the privacy of my personal sandbox.

Programming is not only about communicating w/ computers; it is also about communicating w/ other people, i.e. your coworkers and so on. Nothing that makes it harder can be a Good Thing. (Of course, unless you are the Lone Wolf coding in your cave---but then you are probably using your Own Better Language and don't care about Arc anyway ;-).)

-----

5 points by bgutierrez 6140 days ago | link

I think [... _ ...] is fine. If I want a language to protect me from myself or others, I'll use Java. :-)

-----

1 point by leimy 6138 days ago | link

Freedom is an interesting philosophical topic. How can a restriction make you more free? Well if you drink the FSF GPL Richard Stallman branded Kool Aid, you might "get it", but I sure don't.

I don't want the freedom from doing things, I want to the freedom to do things.

That said, strictness and protection and safety of some language features is something some people would like to rely on.

I think operator overloading in C++ was a huge freaking mistake for instance. You can look at two piece of code without going through some contextual learning to find out what the hell "+" was just redefined to do, and I think that's crappy.

Other languages get by some how without operator overloading. And often without a loss of expressiveness.

That said, judicious use, and education about how subsystems in software work is a necessity even in the presence and absence of things people might consider to be abominations, like operator overloading :-)

-----