newLISP Fan Club

Forum => Whither newLISP? => Topic started by: Cyril on June 25, 2009, 03:22:11 PM

Title: Generic data stucture?
Post by: Cyril on June 25, 2009, 03:22:11 PM
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)
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))
2010
> (t 'year (+ (t 'year) 1))
2011


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?
Title:
Post by: cormullion on June 26, 2009, 08:26:55 AM
Answers: Possibly. Possibly. Possibly. :) And Yes - I think that looks pretty useful! I'll try it out and see how it fits.