[CM] How to make new applicable objects that use generic set/get?

Christos Vagias chris.actondev at gmail.com
Wed Jul 29 13:18:54 PDT 2020


Hi Iain,

Do you really need the "foobar" to be like a keyword? (the : prefix)
If not I, guess one would go like

;; foobar of default value 0
;; you could use define* to denote the  defaults and override them
(define (make-state)
(let ((foobar 0))
  (curlet))

and then
(define my-state-thing (make-state))

;; getter
(my-state-thing 'foobar)

;;setter
(set! (my-state-thing 'foobar) 99)

On Wed, 29 Jul 2020 at 21:59, Iain Duncan <iainduncanlists at gmail.com> wrote:

> Hi S7 Schemers, I'm hoping someone can help out, or point me at some
> beginner friendly resources as I'm not able to figure this out from the
> S7.html page. I am making a state management container for my max apps. I'd
> like to make it follow the generic applicable syntax so that one can call
> it as if it's a hashtable, allowing code using this to be unaware of
> implementation. So I want to implement a setter and getter for my function
> to be able to do:
>
> ;; call my setter
> (set! (my-state-thing :foobar) 99)
>
> ;; call my setter
> (my-state-thing :foobar)
>
> I apologize if this is just basic scheme ignorance!
> thanks
> iain
>
>
> _______________________________________________
> Cmdist mailing list
> Cmdist at ccrma.stanford.edu
> https://cm-mail.stanford.edu/mailman/listinfo/cmdist
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cm-mail.stanford.edu/pipermail/cmdist/attachments/20200729/7430891e/attachment.html>


More information about the Cmdist mailing list