Arc Forumnew | comments | leaders | submitlogin
Update: clearer +, inverse trig functions
9 points by pg 5631 days ago | 11 comments
I just released a new version of arc3.tar with clearer semantics for +.

http://ycombinator.com/arc/arc3.tar

Now the behavior of + simply depends on the type of the first argument. If it is a string or character, it coerces all the remaining arguments to strings. I found I was having to think about when to use + and when to use string. Now the answer is that you should generally use +, and only use string when you have to coerce even the first argument.

The latest version also lets arcsin, arccos, and arctan show through.

Soon I'll start to put the latest version at arc4.tar, but these changes should not break any program that worked before.



4 points by adm 5629 days ago | link

just a thought..

  > (def isregfile ..)
  > (def isdir ..)
  > (def issymlink ..)
  > (def isdotfile ..)


  > (mac filternil ...)


  > (= goodfiles (filternil (map isdotfile&isregfile (dir "/home/me"))))
  > (= badfiles (filternil (map isdir|issymlink (dir "/home/me"))))
I prefer & over +.

-----

1 point by conanite 5629 days ago | link

Ditto for &

Unfortunately | is reserved in scheme for symbols with special characters, so isdir|issymlink would be hopelessly confusing

  arc> (assign |
  | 10)
  10
  arc> |
  |
  10
Maybe an arc implementation of 'read might overcome this.

-----

1 point by Adlai 5629 days ago | link

Or we could use ^ for disjunction.

-----

1 point by fallintothis 5628 days ago | link

But ^ is the symbol for conjunction, i.e. "and"-ing (well, not the literal caret, but the upwards-pointing symbol -- $\wedge$ in Latex). Did you mean to suggest ^ instead of +?

-----

2 points by rntz 5630 days ago | link

There's a bug in your updated '+. It uses scheme's 'list? to check whether a given argument is a list to be converted - but 'list? only returns #t on proper lists (those that end with ()), and arc lists end with 'nil. So, for example:

    arc> (+ "" '(foo))
    Error: "Can't coerce to string (foo . nil)"
A simple solution is to change the use of list? to pair?, since 'nil and '() are both handled earlier in the cond expression.

Also, having a 'coerce-string function for coercing arguments to '+ to strings and not using it in 'coerce seems odd - if (+ "" x) and (coerce x 'string) behave differently, that's just unintuitive complexity, and if they behave the same, then some common code should be factored out.

-----

1 point by pg 5629 days ago | link

Thanks, both fixed in the latest arc3.tar.

-----

3 points by conanite 5631 days ago | link

the behavior of + simply depends on the type of the first argument.

Just curious, is this change for simplicity or for performance?

-----

5 points by pg 5630 days ago | link

Simplicity. I had to keep thinking about when I could use + and when string. But it might improve performance; I haven't checked.

-----

1 point by rntz 5630 days ago | link

"Soon I'll start to put the latest version at arc4.tar"

Wait, does this mean you're planning on releasing arc4.tar soon? Or just that, if you at some point have more changes to make, you'll release them as arc4.tar?

-----

1 point by pg 5630 days ago | link

The latter.

-----

3 points by tc-rucho 5630 days ago | link

Hg/Git FTW ;)

-----