Arc Forumnew | comments | leaders | submitlogin
What I'd like to see in Arc (or in the docs)
10 points by mdemare 6177 days ago | 17 comments
I'm currently programming in Ruby, so that probably colors my opinions.

- Syntax: Being a lisp-like, there isn't much, but what are valid identifiers for instance?

- Integers and floats - size and precision, basic operations (arithmetic and bitwise operations). I could't find the exponentiation or the modulo operators for instance.

- Strings - Are they like ruby (1.8) strings, basically byte arrays with a given size, without awareness of encodings?

- Regular expressions. Mzscheme probably has them, but how to use them?

- It's built on scheme, so does it have tail call optimalization?

- Continuations - are they supported?

- Slices for lists and strings. s[1,2] means starting from pos 1, two values, s[1..3] means starting from pos 1 until (including) pos 3, s[1..-3] means starting at pos 1 upto the third value from the end.

- Ranges! They are surprisingly useful. Defined as two values of the same type that react to comparisons and succ.

- Namespaces. Every language needs namespaces, and better sooner than later.

- each - how to break out of an each loop?

- Enumerables. The Ruby equivalents of functions like keep,rem,all,some,map are all defined in terms of 'each' - any datastructure that responds to each can also use the methods in the Enumerable.

That works fantastic! Arrays, hashes, ranges, strings, sets, bitsets, input streams etc. all have the same interface. But Arc doesn't have polymorphism, so there's only one 'each' function, which only works on arrays. How to make this work?



6 points by Zak 6176 days ago | link

I can answer a few of these.

Tail call: yes, and it actually seems to be faster than mzscheme with a factorial function I benchmarked earlier.

Continuations: call/cc is ccc.

Slices: see subseq.

Ranges: there's a range function that works by successively adding 1, but that's not really what you're asking for.

-----

2 points by cratuki 6175 days ago | link

It would be great if we could have a documentation system that basically formed a tree of use-cases (perhaps inspired by the python documentation, ACL and PCL to start with) and then contained tutorial style guides on using functionality for different outcomes.

Current thinking: a series of html pages that form a tree of headings, with each linking to a blog entries. People could add recommended modifications through the blog comments, and then I could filter that into a tight set of technical documentation, all in the same style.

Reader - if you're enthusiastic for this let me know ideas for variations - I'm finishing a contract today and could start setting something up like this tomorrow. The timing of this release is good for me.

-----

2 points by ryantmulligan 6176 days ago | link

String interpolation.

  (let var "world" 
    (prn "hello #{var}"))

-----

1 point by fallintothis 6176 days ago | link

Why string interpolation when the functions take any number of parameters?

  (let var "world"
    (prn "hello " var))
Or, if you want the entire string, this + tostring (as mentioned here: http://arclanguage.org/item?id=202).

  (tostring
    (let var "world"
      (prn "hello, " var))) 
prn used alone would have a return value of simply "hello, ". With tostring, the return value is "hello, world\n".

Though it might be worth noting that in the source file, arc.arc, there looks to be the beginnings of a printf-like function:

  (let argsym (uniq)
  
    (def parse-format (str)
      (rev (accum a
             (with (chars nil  i -1)
               (w/instring s str
                 (whilet c (readc s)
                   (case c 
                     #\# (do (a (coerce (rev chars) 'string))
                             (nil! chars)
                             (a (read s)))
                     #\~ (do (a (coerce (rev chars) 'string))
                             (nil! chars)
                             (readc s)
                             (a (list argsym (++ i))))
                         (push c chars))))
                (when chars
                  (a (coerce (rev chars) 'string)))))))
    
    (mac prf (str . args)
      `(let ,argsym (list ,@args)
         (pr ,@(parse-format str))))
  )
So that you could say, apparently:

  (let var "world"
    (prf "hello, ~" var))
Granted, the hello world example isn't very illuminating as to the benefits of using prf over the regular pr / prn. But, hey, the option's there in some base form (after all, the code's rather experimental at this stage).

-----

1 point by ryantmulligan 6176 days ago | link

Why does prn only return the result of its first argument?

  arc> (prn "hello, " "world")
  hello, world
  "hello, "
Can anyone think of when this is useful at all?

-----

2 points by eds 6174 days ago | link

This is exactly how print, et al work under CL.

I suspect it is a debugging thing. Since pr and prn return their first argument verbatim you can put them in the middle of working code to find what the return value of something is, without breaking anything. As a trivial example:

(+ (prn 2) 3) ; prints 2 and returns 5

Maybe you wouldn't need it if you had a fancy debugging suite, but it can be useful if you are debugging manually.

-----

1 point by bogomipz 6176 days ago | link

I think the reason is that returning the concatenation would be very expensive. It would basically require a temporary write stream just to put together the return value. In the majority of cases, the return value is probably not even used.

To get the effect you want, simply concatenate as a separate step:

  (prn (string "hello, " "world"))

-----

1 point by akkartik 6176 days ago | link

But why not return the last element?

-----

5 points by akkartik 6176 days ago | link

No, there's a better way. tostring is #$%#ing brilliant.

-----

5 points by tjr 6176 days ago | link

Continuations:

arc> ccc

#<primitive:call-with-current-continuation>

-----

4 points by scimon 6176 days ago | link

The British Pound sign. Or to put it another way Unicode support out of the box. The Pound symbol is the bane of my existance for the very reason that most programming languages get round to Unicode a bit later.

-----

5 points by tjr 6176 days ago | link

Modulo operator:

arc> (mod 23 4)

3

-----

2 points by papersmith 6176 days ago | link

Anyone noticed any of these?

- error handling

- blocks

- multiple-value return & binding

- symbol-macros

-----

2 points by simonb 6176 days ago | link

Aren't blocks just a special-case of ccc?

-----

1 point by papersmith 6176 days ago | link

You're right. I guess it's the same for the conditions system. It'd still be nice to have at least the condition handling operators built-in though, considering that they are used quite often.

-----

1 point by lojic 6176 days ago | link

Robust concurrency support.

-----

5 points by lojic 6176 days ago | link

Regular expressions +1

-----