Arc Forumnew | comments | leaders | submitlogin
Dot notation and doc in general
1 point by d0m 5212 days ago | 5 comments
I was trying to understand the dot notation and its usefulness. However, I can't find any documentation related to it.. and PG's tutorial don't seem to mention it.

When you have a question like this.. do you go directly to the source file to view how the dot is implemented? Or is there another resource I don't know about?



3 points by prestonbriggs 5212 days ago | link

Offhand, I can think of 3 places where dots are used in Arc. 1) for improper lists (where the cdr of the final cons is not nil), 2) in parameter lists, to indicate that all remaining arguments are to be collected into a list and assigned to a single parameter, and 3) as a syntactic abbreviation. I'm guessing you're referring to the 3rd use, since it's a departure from earlier dialects of Lisp.

When the compiler sees a sequence of non-whitespace characters, it has to decide what it represents. Might be something important like a parenthesis, a character constant, a string, or a number. If it's none of the above, then it's probably a symbol. But before it decides on symbol, it first checks to see if it's a syntactic abbreviation, looking for for one of the special characters: ".", ":", "&", "!", and "~". If any of those are present, then it's some sort of abbreviation and is handled specially; otherwise it's a symbol.

You can search in ac.scm for "ssyntax" to see how things are implemented. You can experiment using "ssexpand".

Usefulness... Saves typing, right? If you want to see the 5th element of a list, you could type fred.5 or (fred 5) Seems natural for strings, tables, etc.

Same for ":". We all know the classical abbreviations like "cadr" and "cddr", but we can also gen up new ones like car:cdr:cdr:cdr:cdr which yields a function like caddddr that we can pass around in a 1st-class way.

Preston

-----

2 points by fallintothis 5212 days ago | link

I have a write-up about the dot notation (which is part of a broader feature dubbed "ssyntax"), along with a tool that lets you see where/how you can use it: http://arclanguage.org/item?id=11179. Also, a breakdown of the precedence levels: http://arclanguage.org/item?id=11675.

-----

1 point by prestonbriggs 5212 days ago | link

Ah, cool tool. I like it.

Preston

-----

2 points by shader 5212 days ago | link

We also frequently come here and ask other arc hackers. But then it seems like you've already discovered that option ;)

-----

1 point by evanrmurphy 5212 days ago | link

Do you know about http://af.searchyc.com/ for searching the forum? Also useful is Ken Shirriff's documentation at http://files.arcfn.com/doc/.

http://www.paulgraham.com/arcll1.html has a nice high-level discussion of syntax in Arc.

do you go directly to the source file to view how the dot is implemented?

This is certainly encouraged too.

-----