[plt-dev] feature request

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Wed Apr 14 19:35:19 EDT 2010

You know, these Common Lispers have worked out a lot of these things. We should figure out what else they got right. 



On Apr 14, 2010, at 5:18 PM, Eli Barzilay wrote:

> On Apr 14, Matthias Felleisen wrote:
>> A lot of libraries read in file content as lists (or S-expressions)
>> of list-based structures (see csv on planet for one example, which I
>> am currently incorporating to a small degree into
>> 2htdp/batch-io). If I had this structure -- including in teaching
>> languages -- I could easily 'view' these S-expressions/lists as
>> structs, making for much more readable code.
> 
> +1 for the use case (but I don't have an opinion on whether it
> justifies implementing them or not).  And here is how you do it in CL:
> 
> Plain list -- with the default keyworded constructor
> 
>  CL-USER(1): (defstruct (foo (:type list)) x y)
>  FOO
>  CL-USER(2): (make-foo :y 2 :x 1)
>  (1 2)
>  CL-USER(3): (foo-x (list 1 2))
>  1
> 
> 
> Tagged list, with a positional constructor with arguments in reverse
> 
>  CL-USER(4): (defstruct (foo (:type list) :named (:constructor mkfoo (y x)))
>                x y)
>  FOO
>  CL-USER(5): (mkfoo 2 1)
>  (FOO 1 2)
>  CL-USER(6): (foo-p '(1 2))     ; ("-p" is a bad spelling for "?")
>  NIL
>  CL-USER(7): (foo-p '(foo 1 2))
>  T
>  CL-USER(8): (foo-x (mkfoo 2 1))
>  1
> 
> 
> -- 
>          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
>                    http://barzilay.org/                   Maze is Life!



Posted on the dev mailing list.