Arc Forumnew | comments | leaders | submitlogin
cons, acons, list, alist, sym, string... number?
16 points by CatDancer 6106 days ago | 17 comments
cons creates a cons cell, acons tests if it is a cons

list creates a list, alist tests if it is a list

sym creates a symbol

string creates a string

but... number tests if it is a number

for the "arithmetical plus" I mentioned in http://arclanguage.org/item?id=3601, I said, oh, I'd want a function "number" that converts its argument to a number...

  (def number (x)
    (if (no x) 0 (coerce x 'int)))
however that would require renaming number to something else like anumber... which would also be consistent with the naming of acons and alist.


12 points by kens 6106 days ago | link

I'm trying to write some Arc documentation, and the lack of consistency and orthogonality is rather vexing.

For instance, there's no (char "a") to create a character. (string "a" 'b #\c 1) combines all those into a string, but (sym "a" "b") doesn't work. There's also newstring to create a string.

(table) creates an empty table, not a table of its arguments. If you want to convert arguments into a table, you use the inexplicably named "obj". The positive function works on any random type (string, table, whatever) except for a complex number. And coerce pseudo-succeeds for some things: (coerce (table) 'int) returns a table.

And don't get me started on operations that work on lists, vs operations that work on lists or strings, vs operations that work on lists, strings, or tables - it seems pretty random.

-----

1 point by cooldude127 6106 days ago | link

table does make a table out of it's arguments:

  arc> (table 'a 'b 'c 'd)
  #hash((c . d) (a . b))

-----

3 points by almkglor 6106 days ago | link

^^ LOL, I modified that ^^. Didn't want to use (obj ...) because (obj ...) was a macro, and I might want to do things in a function-form.

-----

2 points by kens 6106 days ago | link

Is this the Anarki version? The official version of table takes no arguments.

-----

5 points by cooldude127 6106 days ago | link

yes it is. i didn't realize that table was different in anarki. well, there is always listtab, but seriously, table should work like the anarki version.

-----

1 point by CatDancer 6106 days ago | link

Fixing bugs instead of documenting them is probably better.

-----

6 points by byronsalty 6106 days ago | link

This what is broken in Arc right now - essentially we can't fix anything of this scale (or arguably anything non-trivial). If we do there will be merge nightmares when PG releases the next official version (and every subsequent release). All we can do is mention problems on the forum and hope he notices and changes things in the next official release.

I believe this would be solved if we shared a repository system (git) with PG in which we could sumbit patches which he would hopefully approve and merge in. Or not approve. Or delegate the sifting out the good patches to someone who knows what they're doing / shares the proper vision of arc.

Honestly this is very disheartening.

-----

5 points by cchooper 6106 days ago | link

I don't think that would fix it, as PG would probably refuse most of the patches anyway. It's not like this forum has a lot of traffic. Patches are unlikely to get lost in the flood (12 articles in the last 24 hours, and PG last commented 18 hours ago).

The two ways to get changes into Arc, as far as I can see, are to find a bug or write some real-world code that proves your suggestion is a good one. With so little real-world code around, that means very few changes will make it.

On the other hand, the last release was all about merging News.YC so there's no surprise that it lacks new features. Who knows, perhaps the next one will incorporate half the stuff from Anarki? We have very few data points from which to draw a conclusion.

-----

3 points by projectileboy 6105 days ago | link

Don't be disheartened, brother. It seems to me Mr. Graham gave us all a first cut to get exactly this kind of feedback, but the core language isn't yet fully baked, and so we should acknowledge that we're at the very beginning of a long journey. I'd be surprised if Linus Torvalds was merging in kernel patches from anyone besides himself in 1992.

-----

15 points by projectileboy 6106 days ago | link

If we're throwing out random nitpicks, then I would vote for "number?" as the test function name, with "number" or "num" being the coercing function. I think the SICP style of appending a question mark at the end of boolean functions makes for very readable code, and keeps with the Arc design goal of brevity. I do not like "anum" or "anumber", because I think "a____" should in general be reserved for anaphoric macros, for consistency's sake.

-----

2 points by map 6101 days ago | link

"number?" looks good to me. It's easier to guess what it does than to guess what anumber does. (And that's the type of name that Ruby would use.)

-----

3 points by almkglor 6101 days ago | link

Rather unfortunately, pg is playing around with syntax, and has thus reserved `?' for future syntax.

-----

7 points by byronsalty 6106 days ago | link

Consistency in the builtins would be ideal - I don't care as much what standard is decided.

-----

4 points by stefano 6106 days ago | link

I'd like it to be called anum.

-----

3 points by CatDancer 6106 days ago | link

I like that name too.

-----

1 point by lojic 6106 days ago | link

Isn't anumber more consistent?

-----

1 point by prabuinet 6105 days ago | link

might also consider 'isnumber' or 'isanumber'

-----