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

The patch:

   diff -Nurp 3.1orig/ac.scm 3.1/ac.scm
   --- 3.1orig/ac.scm	2009-08-10 00:42:57.000000000 +0200
   +++ 3.1/ac.scm	2009-08-10 18:59:37.000000000 +0200
   @@ -1127,29 +1127,40 @@
    (define last-condition* #f)
    
    (define (tl)
   -  (display "Use (quit) to quit, (tl) to return here after an interrupt.\n")
   -  (tl2))
   +  (let ((interactive? (terminal-port? (current-input-port))))
   +;    (when interactive? (display "Use (quit) or ^D to quit, blah blah...\n"))
   +    (tl2 interactive?)))
    
   -(define (tl2)
   -  (display "arc> ")
   +(define not-interactive-write-evalres? #f)
   +
   +(define (tl2 interactive?)
   +  (when interactive? (display "arc> "))
      (on-err (lambda (c) 
                (set! last-condition* c)
   -            (display "Error: ")
   -            (write (exn-message c))
   -            (newline)
   -            (tl2))
   +	    (parameterize ((current-output-port (current-error-port)))
   +	      (display "Error: ")
   +	      (write (exn-message c))
   +	      (newline))
   +            (tl2 interactive?))
        (lambda ()
          (let ((expr (read)))
   -        (if (eqv? expr ':a)
   -            'done
   -            (let ((val (arc-eval expr)))
   -              (write (ac-denil val))
   -              (namespace-set-variable-value! '_that val)
   -              (namespace-set-variable-value! '_thatexpr expr)
   -              (newline)
   -              (tl2)))))))
   +	(if (eof-object? expr)
   +	    (when interactive? (display "(quit)") (newline))
   +	    (let ((val (arc-eval expr)))
   +	      (when (or interactive? not-interactive-write-evalres?)
   +		    (write (ac-denil val)) 
   +		    (newline))
   +	      (namespace-set-variable-value! '_that val)
   +	      (namespace-set-variable-value! '_thatexpr expr)
   +	      (tl2 interactive?)))))))
   +
   +; 'aload{1} could be rewritten to just call 'tl (that's part of why
   +; we test for EOF in 'tl2 and not in 'ac), but need to modify 'tl 
   +; to take a file as parameter, and not always read stdin.
   +; Can't trick 'aload{1} using 'with-input-from-file, because there 
   +; would be a problem if the loaded file calls 'read.
    
   -(define (aload1 p)
   +(define (aload1 p) 
      (let ((x (read p)))
        (if (eof-object? x)
            #t
   diff -Nurp 3.1orig/as.scm 3.1/as.scm
   --- 3.1orig/as.scm	2009-08-10 00:42:57.000000000 +0200
   +++ 3.1/as.scm	2009-08-10 18:57:13.000000000 +0200
   @@ -1,16 +1,14 @@
   -; mzscheme -m -f as.scm
   -; (tl)
   -; (asv)
   -; http://localhost:8080
   -
    (require mzscheme) ; promise we won't redefine mzscheme bindings
    
    (require "ac.scm") 
    (require "brackets.scm")
    (use-bracket-readtable)
    
   -(aload "arc.arc")
   -(aload "libs.arc") 
   -
   -(tl)
   +(parameterize ((current-directory (current-load-relative-directory)))
   +  (aload "arc.arc")
   +  (aload "libs.arc"))
    
   +(let ((args (vector->list (current-command-line-arguments))))
   +  (if (not (empty? args))  ; cmdline args are script filenames...
   +      (for-each (lambda (f) (aload f)) args)  ; ...execute them!
   +      (tl)))
Also available (for direct d/l) at http://pastebin.com/f56fbe59e

-----

2 points by patchfrus 6001 days ago | link

Hm. Snif. How do I apply this patch? I said patch -p1 < patch, and only garbage was found. Then I said patch -u -p1 < patch and only garbage was found. Is there anything to be found in this patch that is not garbage? LOL.

%patch -p1 < unix-patch-2.txt patch: Only garbage was found in the patch input.

-----

1 point by palsecam 6001 days ago | link

Ooops yes, apparently the file on pastebin is "corrupted", I don't know why. "@@" are missing. Maybe a bad copy/paste, but this is suprising. Anyway:

(Good) patch re-uploaded at http://dabuttonfactory.com/res/arc-unix.patch

> How do I apply this patch?

   mkdir arc && cd arc && \
   curl ycombinator.com/arc/arc3.1.tar | tar -x && \
   mv arc3.1 3.1orig && cp -r 3.1orig 3.1 && \
   curl dabuttonfactory.com/res/arc-unix.patch | patch -p0
But all this is assuming you want to copy my arborescence:

   arc/
     3.1/       # "my" version w/ patchs
     3.1orig/   # "official", ORIGinal version
     3.0/
     ...
Maybe you'd better look at the diff and manually apply the patch. A good way to start looking at Arc guts ;-) This was how I expected interested people to use the diff. But using `patch' directly is a good solution too :-)

-----

3 points by palsecam 6011 days ago | link | parent | on: Ask Pg: Can you please update tutorial?

Maybe you changed the tuto since that, but if not, see: http://www.arclanguage.org/item?id=9875 (that was 47 ago, on a thread when you announced new features to arc3.tar, which was then "fairly recent").

-----

5 points by pg 6011 days ago | link

Oh, you mean update in the sense of expand? Yes, I'm working on it.

-----

2 points by palsecam 6011 days ago | link | parent | on: As.scm and relative paths

> Official Arc exists to support one app: news.arc

To erikb: yes, don't forget this important point. Sometimes Arc failed on basic stuff, because news.arc/pg's stuff doesn't need it (yet). If you're not going to accept this fact, you'd better not use Arc (or you can do even better: actually improve it to suit your needs :-)).

See also, taken from http://paulgraham.com/noop.html:

There is a danger in designing a language based on one's own experience of programming. But it seems more dangerous to put stuff in that you've never needed because it's thought to be a good idea.

which is wise.

> If you were to write a language to support a single app, you wouldn't need fluff like being able to run from a different working directory. [or, as palsecam put it more eloquently, Lisps in general just consider the OS is crap, and they are too "pure" to talk with it.]

I don't think this is the same idea here.

"Mine" is: you are crazy to create a general-purpose language and completely ignore the rest and the world, i.e the OS and the other programs (not written in your language). (In Common Lisp defense, it was designed at a time the OSes were more diverse & their future uncertain, etc.).

And Arc, as we said, is not so designed to be of general purpose.

And I don't think "if you were to write a language to support a single app, you wouldn't need fluff like being able to run from a different working directory" is totally correct. You can design a language for a single purpose that would include deep cooperation with the OS. E.g: purpose is to write a language to manage firewalling rules.

To conan: anyway, I agree with you in overall ;-)

-----

1 point by palsecam 6011 days ago | link | parent | on: As.scm and relative paths

If you're on a Unix system, you could use an alias: see http://www.arclanguage.org/item?id=10250

-----

2 points by erikb 6011 days ago | link

thx, will try this. But how do you yourself use arc? (Yes, on UNIX. SuSE, Debian, Ubuntu, OS X. But on Windows I would have the same question, I guess. Because it is not described in the install or tutorial text)

And how do you start a script?

in python I just do this: $ python myscript.py

and in php it is this: $ php myscript.php

so I would expect this: $ arc myscript.arc

I wrote a bash script that executes this mzscheme -m -f .... stuff. But still I can't start an arc script from my shell.

It is really strange, it is such a basic stuff, but I can't find it in the install/tutorial text. Maybe there is some way that the lisp or scheme usage in common differs from the usage of other languages like python or php?

-----

4 points by palsecam 6011 days ago | link

> It is really strange, it is such a basic stuff. Maybe there is some way that the lisp or scheme usage in common differs from the usage of other languages like python or php?

Absolutely true. In short, Lisps in general just consider the OS is crap, and they are too "pure" to talk with it. Hence, no easy way to start a script. Hence (also), no popularity because the majority of people live in the real world and not in the ideal lambda calculus one ^^ (this is not that bad with MzScheme or say SBCL [Common Lisp implementation] to be honest)

> But how do you yourself use arc?

Mostly dealing with the fact that it fucks the Unix philosophy, but I patched it to be a little less stupid on that. Sorry, no time now, but I'll post the patch in the near future, although it is not as sufficient as I'd like yet.

To reply more directly: nearly exclusively from the REPL.

-----

2 points by palsecam 6007 days ago | link

> I patched it to be a little less stupid on that. Sorry, no time now, but I'll post the patch in the near future, although it is not as sufficient as I'd like yet.

Done & sufficient now. See http://www.arclanguage.org/item?id=10344. And directly solves the relative paths problem.

-----

1 point by erikb 6003 days ago | link

I saw it before looking here. very nice work! :)

-----

4 points by thaddeus 6011 days ago | link

To launch arc - I use a unix command file:

  #!/bin/sh
  (cd /home/programs/arc;
   /home/programs/scheme/bin/mzscheme -f as.scm)
As for windows read:

http://arclanguage.org/item?id=9263

and

http://arclanguage.org/item?id=9382

Also - here are a few others to read:

1. Starting an arc script: http://arclanguage.org/item?id=9617

2. Easy means to search the arc forum: http://af.searchyc.com/

3. Good documentation: http://arcfn.com/

-----

3 points by erikb 6011 days ago | link

thx guys. I will read more on arcfn.com. I am very happy that there actually is more documentation! And I am still interested to see more information here. Are there other people out there, who have invested some energy in enhancing the usability of arc? Please tell me more!

-----

3 points by conanite 6011 days ago | link

Take a look at anarki, a community-maintained fork of arc with a bunch of enhancements (I don't know if there's a simple list of changes anywhere) ... and rainbow (an arc interpreter in java; mostly the same as arc except for access to java libs; dunno if that counts as "enhancing usability" :))

anarki http://github.com/nex3/arc/tree/master

rainbow http://github.com/conanite/rainbow/tree/master

-----


> too many ways for it to break

> The syntax for this each you're trying to write is suspect

> perhaps you could consider something with a more regular syntax?

You're right. The more I think about it, the less I like this 'each idea.

> All this parsing / partial compilation smacks of over-engineering.

True, but this is also part of the fun here ;-)

> For all I know about Perl (which isn't much), it looks like its foreach works with explicit and implicit variables because you can consistently parse it -- you always have parentheses delimiting the array.

You are absolutely right here, and you made me realize I am actually trying to get something more dirty/complicated than in Perl, which is... really not a good sign :-D!

> Or you could rely on the Scheme reader recognizing curly-braces as parens

This is also an interesting option. Good to know.

> Sorry I don't have any better suggestions.

Gosh, that's already a bunch of good ideas! Thanks!

-----


Your 'every example is very very attractive. I think I'll adopt it at this point:

1. It does the job without problematic cases, like there would be in what I describe:

   (with (lst '(1 2 3)
          v 3)
      [...]
      (myidealeach v lst (prn v)))  ; <-- v mistaken for the seq to traverse here, 
                                    ; because it is defined
2. OK, it adds some syntax and this is bad, but for the common case where I'd like an implicit '_ variable, it's as short as possible!

3. For the other cases, the extra "in" is not so heavy, and in a way it makes the expression more readable!

Thanks a lot absz!

----

For the rest:

> anaphoric each

Yes, a good idea but I don't like to have two loop constructs where one could suffise. Currently, I'm using something like that (I have a 'each_) but this sucks IMO.

However, interesting that you choose to use 'it' and not '_'. It makes me realize, maybe it would be better if there was only one of the 2, there are a bit redundant aren't they?

   (aif (car a) (prn _))  
   ; I like this, because "_" is more visible than "it", less likely 
   ; to be confused with a "normal" variable, and less english-centric 
Or:

   ([* it it] 2)  ; hmmm don't like that so much actually
This is pure personal taste however.

In the same way, this is also personal taste, but I mention this because an American/British people may not think about this kind of stuff. I prefer "list?" over "alist" because anyone used to the latin alphabet will quickly understand what it does (and even this is not the majority of people...). True story, I didn't understand what "acons", "alist" mean when I first looked at Arc (I'm French), while the Scheme way to name predicates was obvious at first sight.

> CL's loop

Ouch I'd really not copy 'loop too much however.

In a way, it is a good construct, I mean it is very powerful, but I can never remember of the syntax to do basic things, and this is why I prefer the Arc way here. 'loop is really a DSL in itself.

Thanks again!

-----

2 points by absz 6012 days ago | link

Glad I could be of assistance :)

As for the it/_ question: I hadn't noticed until writing my post that _ and it (and self in afn) were serving similar purposes; I don't really know which one I like more, though that's not something I care heavily about. (My feeling about the English-centricity problem is that if everything else in the language is already in English---if, each, and, etc.---then changing it to _ probably wouldn't make a huge difference.)

As for the function-naming issue: I also prefer the Scheme naming convention, though not for multiple-language reasons (I'm an American [mais je peux parler Français]); that's an aspect I hadn't thought of. (The a-predicate versus anaphoric thing is already annoying.) Internationalization of programming languages is a hard problem that I don't think anybody's tried to tackle, and I'm not sure how tractable it is---it would be interesting to see a language or framework which tried to explore that design space. The obvious approach is something like

  (mac si (c v f) `(if ,c ,v ,f))
  (= chaque each)
  ; etc.
The downside is that this only internationalizes the core; any library still has to support these synonyms or have a translator, and so I'm not sure how big the eventual gain is. (I think AppleScript had this once, but since applications didn't support this, that feature died.)

In my opinion (and I've barely used CL), loop is a brilliant piece of code because it's a great little DSL for iteration; at the same time, also having simpler alternatives, e.g. each, available is really handy because that way you don't need to know everything loop can do all the time.

-----

2 points by palsecam 6011 days ago | link

> then changing it to _ probably wouldn't make a huge difference

I also don't think it would be a huge difference for non-english programmers, although it may be a little win. But for my case, I don't prefer "_" just because of that. I'd say, the main reason is that "_" is more easily recognized by my parser (aka brain) as a special variable than "it" because it is an uncommon glyph. "it" gets lost in the flow of the program.

> I'm an American [mais je peux parler Français]

Now, that is not common and that is cool. I mean, not that you know how to speak French, but that you know how to speak a foreign language.

Those who know no foreign language knows nothing of their mother tongue. -- Goethe

It's not a coincidence that Larry Wall (Perl creator) studied linguistics...

> that's an aspect I hadn't thought of

Well in this case I can go to sleep happy, knowing I made you aware of something new ;-)

> a-predicate versus anaphoric thing is already annoying.

Yes! When I realized 'acons & the like were predicates, well I thought 'afn was, too...

> loop is a brilliant piece of code because it's a great little DSL for iteration; at the same time, also having simpler alternatives, e.g. each, available is really handy

Totally agreed. 'loop is something great to have as a library or something, but if it's the only way you have to do basic iteration, well, it sucks IMO. Because in top of knowing CL you have to know the 'loop stuff, which is completely different. Gosh, writing this message I realize I don't even remember how to iterate over a list while printing its elements. But yes, 'loop is extremely powerful.

Anyway, thanks once again absz, your message was really interesting to read!

-----


The patch (diff -Nurp):

   --- ac.scm.orig	2009-08-04 21:04:24.000000000 +0200
   +++ ac.scm	2009-08-04 21:21:33.000000000 +0200
   @@ -27,6 +27,7 @@
            ((eq? (xcar s) 'if) (ac-if (cdr s) env))
            ((eq? (xcar s) 'fn) (ac-fn (cadr s) (cddr s) env))
            ((eq? (xcar s) 'assign) (ac-set (cdr s) env))
   +        ((eq? (xcar s) 'defined) ac-defined)  ; to be called later in 'ac-mac-call
            ; the next three clauses could be removed without changing semantics
            ; ... except that they work for macros (so prob should do this for
            ; every elt of s, not just the car)
   @@ -254,6 +255,14 @@
                     ,(ac (cadr args) env)
                     ,(ac-if (cddr args) env)))))
 
   +(define (ac-defined x env)  ; called only via macro
   +  (if (pair? x)
   +      (and (ac-defined (car x) env)
   +	       (ac-defined (cdr x) env))
   +      (or (literal? x)
   +	      (lex? x env)
   +	      (bound? x))))
   +
   (define (ac-dbname! name env)
     (if (symbol? name)
         (cons (list name) env)
   @@ -462,8 +471,9 @@
 
   (define (ac-mac-call m args env)
      (let ((x1 (apply m (map ac-niltree args))))
   -    (let ((x2 (ac (ac-denil x1) env)))
   -      x2)))
   +    (if (procedure? x1)  ; 'defined call
   +	  (x1 args env)
   +	  (ac (ac-denil x1) env))))
  
    ; returns #f or the macro function

-----

3 points by palsecam 6013 days ago | link | parent | on: Arc 3.1 (works on latest MzScheme)

Really nice that it now works with the latest version! Always problematic to depend on old stuff IMHO.

Tested on Debian (Squeeze) with MzScheme 4.1.4 (the one in the official repositories), no problem :-)

Note: don't use 'mzscheme -m -f as.scm' but just 'mzscheme -f as.scm' instead (see "how-to-run-news").

For information, the 'coerce / 2.0 integer is fixed by defining an Arc integer (exint) as (and (integer? x) (exact? x)). The bug with dotted lists in quasiquote is fixed using a new small function 'imap, that is like 'map but "don't demand '()-terminated list".

-----

1 point by palsecam 6013 days ago | link | parent | on: Starting up with Arc

Oh yes, I didn't remember of pushd/popd!

Really handy in this case.

Thanks for the tip!

-----

3 points by palsecam 6014 days ago | link | parent | on: Atstring problem

I agree the interpreter behaviour is kind of strange here.

Anyway, if you don't already know it, use "@@" to escape "@", and not "\@".

-----

2 points by pg 6013 days ago | link

Right: @@ to escape. Eventually I'll take over the reader, but it's not the top priority at the moment.

I'm not sure I'll even keep @strings. I find I don't use them as much as I expected. Does anyone use them a lot?

-----

1 point by rntz 6012 days ago | link

I find them quite useful for my irc bot, although I do run into the problem of not being able to @-substitute a simple variable unless it's going to be followed by something not permissible in a symbol. In particular, colons will be parsed as part of the symbol, which is a PITA. There is a workaround for this, but it's ugly:

  arc> (with (nick 'hbovik msg "hullo there") "@(idfn nick): @msg")
  "hbovik: hullo there"

-----

1 point by coconutrandom 6012 days ago | link

I tried for half a second, but dropped it in favor of string substitution.

-----

More