Arc Forumnew | comments | leaders | submit | kennytilton's commentslogin
3 points by kennytilton 6709 days ago | link | parent | on: Another, older wannabe neo-Lisp

I am working on a "lite" version of Cells for Arc as we speak (rough start here http://common-lisp.net/cgi-bin/viewcvs.cgi/kennysarc2/cells-...) and I do think a logical step after that would be exploration of applying that to a web app. Unfortunately I have not mucked with interwebby programming so I really would not know where to start. And it might make more sense for me to start with a Common Lisp library such as Hunchentoot. Stay tuned.

-----

4 points by almkglor 6709 days ago | link

Wow Cells! All right, I just heard a lot of enthusiasm for Cells on c.l.l but never managed to grok much of it (insufficient docs IMO); it would be interesting how you handle the mutation of objects - there's no hook in Arc for that yet.

From the looks of this framework it's a test specification.

Incidentally, arc.arc already defines an (obj ...) macro. Do you intend to redefine it?

-----

1 point by kennytilton 6709 days ago | link

Thanks, but I think all the enthusiasm on c.l.l is from me. :) Maybe when I provide a Web app example people will get fired up. (I am a dinosaur, thought a desktop GUI would do the trick);

   http://common-lisp.net/project/cells-gtk/
As for controlling change, right, my-obj!my-slot will be a backdoor, Arcells (name?) will have to work via readers/writers that invoke the Arcells engine.

Framework? Test spec? What I have so far is merely motivational examples (and I am using the OBJ macro, not redefining it):

   http://smuglispweeny.blogspot.com
Look for (+ Arc Cells) Baby Steps, which I am mopping up once the caffeine hits my cortex. When done I'll submit a new thread.

-----

1 point by kennytilton 6709 days ago | link | parent | on: Two part noob question

Right, but I think the different approach to the splicing was sound and simpler for noobs:

  (def report-result (result form)
    (prn)
    (prn form)
    (prs '-> result)(prn)
    (prn))

  (mac check args
    `(do ,@(do (map (fn (test)
                    `(report-result ,test ',test)) args))))
I think I transliterated to the _ form accurately, but this commented out bit gives me an error from CAR.

;;; so why doesn't this work? ;;;(mac check args ;;; `(do ,@(do (map [`(report-result ,_ ',_)] args))))

Anyway, this then produces the expected results:

  (check
   (is (* 6 9) 42)
   (is (* 6 9) (coerce "42" 'int 13)))
The above should fail the first, pass the second, tho Adams denied knowing that was what he was going on about.

-----

3 points by almkglor 6709 days ago | link

  [`(report-result ,_) ',_]
becomes:

  (fn (_) (`(report-result ,_) ',_))
If you notice, whenever a macro in arc.arc wants to use `(), it avoids using the [... _ ...] syntax for it.

-----

2 points by kennytilton 6709 days ago | link

Oops, that extra "do" wrapping just the map was left over from debugging the macro and can be chopped. Note to noobs: this is also a macro-writing tip to remember, one can put debugging print statements that run as a macro gets expanded to help debug and even learn how to write macros.

-----

1 point by kennytilton 6711 days ago | link | parent | on: Stupid noob question

Do either of those support CL-style defmacro?

-----

1 point by Jekyll 6711 days ago | link

Dr Scheme does. Fire it up, click language then choose language. Pick "pretty big", then (define-macro ...) will do pretty much what you expect. http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme-Z-H-...

-----

1 point by mec 6711 days ago | link

Side question here, is there a keybinding anywhere in DrScheme to close all open parentheses? It's driving me crazy trying to find it.

-----

1 point by danielprager 6710 days ago | link

Dunno, but the '[' and ']' keys in DrScheme are clever enough to give you '(' and ')' when you need them (and '[' and ']' at other times).

Since discovering this I just keep tapping ']' until the highlighting tells me I'm done.

-----


Still work compared to converting (in my case) (+ x 42) to (ekx hi-mom + x 42). Subtext: I have watched Emacs users edit code... reminds me of a Nascar pit stop.

-----

1 point by evanm 6710 days ago | link

do you mean (ekx hi-mom (+ x 42)) ?

if you are inside the (+ x 42), type C-, to move just before the parenthesis, then C-1 [ to insert parentheses around the expression, then type "ekx hi-mom ".

In short: C-, C-1 [ ekx hi-mom

-----

1 point by kennytilton 6709 days ago | link

No, the idea was to add/remove tracing without adjusting the parens (I hate typing), so (ekx xxx + 2 2) as strange as it looks does eventually expand in part to the form (+ 2 2).

-----


Here is my CL hack to avoid parens juggling, automated or not:

  (defmacro ekx (ekx-id &rest body)
    (let ((result (gensym)))
     `(let ((,result (,@body)))
         (trc ,(string-downcase (symbol-name ekx-id))
              :=> ,result)
         ,result)))
(ekx weird-result + 40 2) -> weird-result :=> 42

I think my TRC function can be easily converted to standard CL. Of course, none of thus addresses the fancier tricks you talked about above, such as (+ prn:x 42).

-----

1 point by kennytilton 6714 days ago | link | parent | on: macro / function question

I see you have corrected the above by switching to a different name (a reasonable way to go) but it might be fun to see if you can stick with one and expand differently based on whether one or more than one value is supplied (meaning of course you need to support what we call &rest in CL in the parameter list of twodimlist. What I do not know is how well Arc likes to expand a macro into code referencing the same macro.

-----

1 point by kennytilton 6714 days ago | link | parent | on: macro / function question

Sorry, my Arc is rusty, did you mean:

  (def ls (x y) ((list x) y))
My next question would be what that has to do with your original query, and my question there would be what does this do?:

  ((twodimlist 0) 3)

-----

1 point by bOR_ 6713 days ago | link

I've a function that binds a list of lists to to variable 'world', and a function that prints out this world.

  (def makeworld (x)
    (let z nil
      (repeat x (= z (cons nil z)))
      (repeat x (= z (map [cons nil _] z)))
    (= world z)))

  (def show ()
    (each x world
    (each y x
    (pr (if (is y nil) #\. y) #\space))
    (pr #\linefeed)))
The world can then be seeded with trees, or shrubs or monsters or whatever. Anyway, as the world is a list of lists, it functions as a two-dimensional array.

If in arc I want to access a point in this two-dimensional list / array, I need to enter ((world 0) 3), and the basic question was how to change arc (macrowise) to make (world 0 3) be equivalent to ((world 0) 3). I already worked around it by now.

To answer your question: you're assuming that there is a list called 'list', and in my initial example I described a function that took the name of the list as first argument.

-----

2 points by fallintothis 6712 days ago | link

The problem with multiple values being subsequent accesses is it would also interfere with a useful syntax (not actually in Arc, but I mean insofar as deciding which it should mean), and that's subsequence indexing. It's been discussed all over the place, e.g. http://arclanguage.org/item?id=449

With the assumption that one of them takes that syntax, what should be used for the other? How about (seq '(0 3 ...)) or (seq (0 3 ...))? It would similarly be fitting for any number of arguments, be they dimensions or indices, though I would vouch to use the list for n-dimensional indexing as the case of subsequences seems more common. Plus the use of a list distinguishes the one type of access from the other without having to go (...((seq 0) 3) ...).

Not that any of this helps your problem. Just something I noticed.

-----

1 point by kennytilton 6713 days ago | link

Oh, I get it. No, this is not something you can do with macrology because there is no room for a macro in your desired syntax (where you just want the list itself and the index values). As you say, if you'll make room for another token it can just be a function (which would be fun to generalize to N dimensions). As for making ((list (list 42)) 0 0) return 42, I think you need to is suggest it as a (very reasonable) enhancement to Arc.

-----

2 points by pg 6713 days ago | link

I don't understand exactly what this code is for, but I think you could write makeworld as

  (def makeworld (x)
    (= world (n-of x (n-of x nil))))

-----

4 points by kennytilton 6714 days ago | link | parent | on: Symbols ending in *

Just a naming convention, but it is such an insanely easy convention to follow and recognize that what could be an absolute nightmare (dynamic binding outside the lexical scope being unwittingly shadowed and broken by an innocent choice of variable name) simply never happens. Almost like magic. :)

-----


How many thousand lines of Lisp have you coded? What did your biggest Lisp application do? Or were you just guessing at what it is like to program large applications in Lisp and in team situations?

-----

2 points by kennytilton 6714 days ago | link | parent | on: defstruct in Arc

This is an extremely lite version (the CL defstruct has a kazillion fetaures, it's CL <g>):

http://common-lisp.net/cgi-bin/viewcvs.cgi/kennysarc2/?root=...

Don't be thrown by the .lisp extensions, it is Arc, I just had to fake my IDE into auto-highlighting the parens.

-----

More