Arc Forumnew | comments | leaders | submit | almkglor's commentslogin

I suspect what confused you here is the assumption that scanners work like input streams: once you execute (readc stream), the stream state changes. However, scanners are functional and are equivalent to monads in this case; if you keep the old version of the scanner, it's still the old state of the scanner that you'll use.

-----

3 points by almkglor 6392 days ago | link | parent | on: Don't understand how macros work

Then use 'eval :

  (ontable k v h
    (eval `(= ,k ,v)))
Note that this does not copy to the current environment, just the global environment. So if you're doing something like this:

  (let foo 42
    (= h (table 'foo 1)) ; Anarki only
    (ontable k v h
      (eval `(= ,k ,v)))
    foo)
Then the 'foo you access is the local one, but the one written by 'eval is the global.

-----

3 points by absz 6392 days ago | link

Careful! You're evaluating the value of v here, which can break:

  arc> (ontable k v (table 'var 'a)
         (eval `(= ,k ,v)))
  Error: "reference to undefined identifier: __a"
You need to quote the value of v here to prevent it from being evaluated; when you do so, you get

  arc> (ontable k v (table 'var 'a)
         (eval `(= ,k ',v)))
  #hash((var . a))
  arc> var
  a
And then the body of he loop is the same as the body of my assign function from http://arclanguage.org/item?id=6918.

-----

1 point by almkglor 6392 days ago | link

This is correct ^^

-----

2 points by zhtw 6392 days ago | link

> Note that this does not copy to the current environment, just the global environment.

Yeah, I'm aware of that. But it's a good point anyway, thanks.

-----

5 points by almkglor 6392 days ago | link | parent | on: Don't understand how macros work

> Lisp is what you want it to be, not pg's fundamentalist view on it.

The Turing Machine can be anything you want it to be, but it's not always easy - or desirable - to force the machine into doing what you want.

You can use hedge clippers to cut your toenails, but I doubt you'd want to do that.

-----

2 points by almkglor 6393 days ago | link | parent | on: Kenny Tilton, ranting

> Lisp meanshile is as good (and superior) as it ever was

Really, kenny, lisping while you type? You must be drinking even more than usual... ^^ \/

-----

3 points by almkglor 6393 days ago | link | parent | on: Libraries TODO list now on Anarki

http://github.com/nex3/arc/wikis/libraries-todo-list

-----

4 points by almkglor 6394 days ago | link | parent | on: Local Scopes?

> 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 6392 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 6392 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 almkglor 6394 days ago | link | parent | on: Chalk one up for Arc

LOL. Let us therefore officially decree that Anarki is the official Arc. ^^

-----

3 points by stefano 6394 days ago | link

That's right! :)

-----

3 points by almkglor 6394 days ago | link

LOL. And therefore ArcN is the Decreed Unofficial Canonical Arc.

-----


http://arclanguage.com/item?id=6892

Do you have any particular examples which make you think that it doesn't? Arki, the wiki in Anarki, makes use of (zap cdr s) on scanners quite a bit.

-----

3 points by almkglor 6395 days ago | link | parent | on: (delist somelist)

Since Arc is a language targeted for the web... have you considered the possibility of generating a web page for it, with maybe next >> and << prev links?

-----

1 point by bOR_ 6394 days ago | link

That might actually work, and just autorefresh the page every second or so :)

First priorities now are finishing the wandering algorithm for the animals so that they're no longer steered but steer themselves, and generalize the code I've some more so that adding more behaviours than just biting things is easy. I'll add the visuals-through webpage idea to that list :)

-----

5 points by almkglor 6395 days ago | link | parent | on: Chalk one up for Arc

> That being said it sucks that the arc community uses Anarki while pg doesn't. Or at least he doesn't contribute regularly. I think there is plenty of room for a more cohesive community.

Second that!

-----

More