Assignment/SETF macro

Brian Rice water at tunes.org
Mon Mar 6 02:32:51 PST 2006


This has been extended so that any selector #foo: for which #foo:put:  
has been defined will be handled accordingly.

On Jan 27, 2006, at 12:10 PM, Brian Rice wrote:

> I've added a macro `setTo: to macro.slate. See near the end of:
> http://slate.tunes.org/repos/main/src/lib/macro.slate
>
> Right now, all it does is expand some basic forms:
>
> (x atSlotNamed: #foo) `setTo: 4. => x atSlotNamed: #foo put: 4.
> (x at: 3) `setTo: 4. => x at: 3 put: 4.
> (x at: 'key') `setTo: 4. => x at: 'key' put: 4.
> x foo `setTo: 4. => x foo: 4.
>
> It is aliased as an empty keyword `: and binary `:= as well.
>
> Benefits: The only benefit of it is to be able to "identify"  
> assignment idioms more easily in code, but that seems worthwhile. I  
> suppose it's possible to use it for code-generation as well, to  
> abstract over assignment types, but I don't have a use-case in that  
> direction yet - perhaps if I extended the C Syntax types with the  
> same selector...
>
> Deficiencies: Type inference is not standardly used in Slate yet,  
> so it can't infer whether or not something is an array or  
> dictionary or even /has/ a (settable) #foo attribute as in the last  
> case. This could happen in the future, though.
>
> Ideas, suggestions, complaints? Thumbs up or down? Let me know.  
> This was an easy addition, really.
>
> NB: "SETF" refers to the "set field" macro in Common Lisp, which  
> inspired this.

--
-Brian
http://tunes.org/~water/brice.vcf

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
Url : /archives/slate/attachments/20060306/63ddf136/PGP.pgp


More information about the Slate mailing list