Arc Forumnew | comments | leaders | submit | applepie's commentslogin
-1 points by applepie 6207 days ago | link | parent | on: Local Scopes?

Because "=" is confusing and encourages the use of global variables.

IMHO, Arc got scope wrong, mixing definition with assignment. Didn't we learn from Python? (i.e. it's sad to see the same mistakes once and again).

-----

4 points by almkglor 6207 days ago | link

> Didn't we learn from Python? (i.e. it's sad to see the same mistakes once and again).

Eh? What mistake? THe only mistake I see in Python is the difficult anonymous function syntax and lack of Lisp macros.

-----

1 point by applepie 6205 days ago | link

  def make_counter():
    x = 0
    def inc():
      x = x + 1
      return x
    return inc

  c1 = make_counter()
  c1() # returns 1
That's Python.

It might seem nice at first glance :)

But... oops! it doesn't work.

It doesn't work because the "x" in "x = x + 1" is _not_ the same "x" as in "x = 0".

And that happens because definition and assignment are badly mixed up.

-----

4 points by almkglor 6205 days ago | link

...and? The equivalent (and correctly running!) Arc code is:

  (def make-counter ()
    (let x 0
      (fn ()
        (= x (+ x 1)))))
So... why do you want to avoid 'let ?

-----

3 points by skenney26 6207 days ago | link

Recently I've been thinking alot about scope and would be interested in hearing you expound on what Python and Arc got wrong.

-----

1 point by bOR_ 6207 days ago | link

Isnt' the massive use of global variables not something that is only for newbies?, and from which you learn what is bad about it by experience?

in which case it is no longer a problem for most of us ;)

-----

8 points by applepie 6213 days ago | link | parent | on: Arc3.tar

Don't worry, according to his own philosophy, pg just has to complete the final (f) step :)

"Here it is: I like to find (a) simple solutions (b) to overlooked problems (c) that actually need to be solved, and (d) deliver them as informally as possible, (e) starting with a very crude version 1, then (f) iterating rapidly."

(On _Six Principles for Making New Things_)

-----

4 points by applepie 6234 days ago | link | parent | on: Obfuscated Arc

I think pg means to allow anything _in the language_, not in the applications

-----

4 points by applepie 6236 days ago | link | parent | on: Will/Can Arc create a LISP-revival?

> the fact that code is specification makes it easier

The fact that broken pg's code is specification is a pain in the back and doesn't make anything easier.

Read RnRS for a _real_ specification of Lisp.

-----

3 points by sacado 6236 days ago | link

I was not talking in practice, in was meaning "in theory". In theory, the fact that most of the language is specified via code helps avoiding incompatible implementations. In practice, that's another problem, but it's only the beginning...

-----

2 points by almkglor 6236 days ago | link

Where pg fails.... --warning-blatant-self-promotion-- Anarki! Whee!

Hmm. Probably need a "Report on Anarki" as a spec of the standard Anarki, particularly 'call* and 'defcall, which may very well be the most important extension in Anarki.

-----

2 points by applepie 6276 days ago | link | parent | on: Poll: Where are you from ?

Argentina

-----

1 point by applepie 6299 days ago | link | parent | on: Arc through web forms?

Installing Arc to try it on a browser is no fun. I meant evaluating Arc through forms, without having to install it.

-----


The colon proposal attempts to be orthogonal to traditional s-expression notation (every s-expression in traditional notation keeps reading the same as always, no matter how it is formatted).

> I like the idea of indentation based syntax, but the colon solution looks like only half a solution

Well, if we want to read s-exprs, _somehow_ the programmer must hint the reader about where the parens go.

I don't want the reader to guess what I mean, or juggle with whitespaces.

I think the colon notation is more visually appealing than "just parens", and doesn't hurt programmers who don't want to use it.

-----

2 points by cadaver 6299 days ago | link

Since, as I've pointed out, the editor can handle the parens for you completely and unabiguously, even without any special commands, you could simply turn-off, parens that exist in addition to indentation, make them invisible.

If you then additionally make the editor display the opening parenthesis as a colon then, voila, you have the visually pleasing colon syntax.

In such a mode you'd always have to be indentation perfect, but just as with colon syntax, you can simply switch to a more traditional editing mode.

-----

2 points by applepie 6299 days ago | link | parent | on: Python-like generators in arc

Ugh, the code was wrong. I'm starting to think that Arc didn't really learn the lesson (i.e. getting scope right).

IMHO, it would be cleaner if def behaved more like Scheme's internal define (i.e. create a new local binding and set!).

I'd keep the current behaviour of def under the name defglobal or something.

-----

3 points by nex3 6299 days ago | link

I added an "lset" form to Anarki that works just like Scheme's define.

-----

2 points by applepie 6299 days ago | link | parent | on: Monadic-like macro

Now it behaves as Haskell's do-notation for the identity monad.

It could be adapted for other monads if it also took return and (>>=) as arguments.

  (mac w/ (monad x . rest)
    (w/uniq (gmonad)
      ((afn (x rest)
         (if (no rest)
           `(let ,gmonad ,monad ,x)
           (self `((car ,gmonad) (fn (_) ,(car rest)) ,x)
                 (cdr rest))))
       `((cdr ,gmonad) ,x))))

  (= list-ret list)
  (= list-bind mappend)

  (= list-monad (cons list-bind list-ret))

  (w/ list-monad 10
     (list (- _ 1) _ (+ _ 1))
     (list _ (* _ 2) (* _ 3)))

  ===>
  (9 18 27 10 20 30 11 22 33)

-----

1 point by applepie 6299 days ago | link | parent | on: Python-like generators in arc

I don't understand how it relates to generators (?)

-----

1 point by almkglor 6298 days ago | link

  (mac lcc (name . body)
    `(ccc (fn (,name) ,@body)))
Please use Arc built-ins as much as possible instead of defining your own.

Come to think of it, pg should really make the docstrings mod official, and he most definitely needs to put docstrings in his own code.

-----

2 points by applepie 6298 days ago | link

Why?

I'm programming for myself, not for you. You can use, modify, improve or drop the code if you find it useful, but don't tell me what I should and what I shouldn't do.

-----

3 points by kennytilton 6298 days ago | link

I think the suggestion was just phrased a little awkwardly.

Lisp is so easy to program that it is commonplace to reinvent builtins -- they are as easy to write as they are to find (especially in an, er, mildly documented language).

I went proactive on reinvention thang and invited people to let me know of things I had reinvented. Somewhat tangentially, I also make an effort to use things like [... _ ...] and func.arg to give pg's ideas a fair test and so my Arc code can help other noobs get up to speed on the language. If I stay as close as I can to my preferred Common Lisp, like someone writing C in Common Lisp neither I nor anyone else gets a feel for Arc. But I digress.

-----

More