Generic data stucture?

Started by Cyril, June 25, 2009, 03:22:11 PM

Previous topic - Next topic


Maybe I am reinventing the wheel, but this pattern seems useful for me:

newLISP v.10.1.0 on Win32 IPv4, execute 'newlisp -h' for more info.

> (define (Struct:Struct) (apply context (cons (context) (args))))
(lambda () (apply context (cons (context) (args))))
> (new Struct 't)
> (map t '(year month day hour min sec micro doy dow tz dst) (now))
(2009 6 25 22 8 49 219840 176 5 2009269136 5251736)
> (setq t:year (+ t:year 1))
> (t 'year (+ (t 'year) 1))

A generic data structure which fields are accessible by both colon and functional notations. The later is useful for group assignment. And now I have a bunch of questions: do I reinvent the wheel? do I mislooked some caveats? can this be made simpler? does this seem useful after all?
With newLISP you can grow your lists from the right side!


Answers: Possibly. Possibly. Possibly. :) And Yes - I think that looks pretty useful! I'll try it out and see how it fits.