Assignment/SETF macro

Bill Sun billksun at yahoo.com
Sat Jan 28 14:20:30 PST 2006


Thumbs up :)

This looks like it could also be applied to a previous
discussion with regards to mutator methods being
confused with verb message sends
(http://thread.gmane.org/gmane.comp.lang.slate.general/863).
 At least the message intent to the reader is clearly
distinguished this way.  The mutator could then be
changed to something that would avoid conflict with a
possible verb message send of the same name. It could
even be something obscure, but using `setTo will
clearly express the intent of the code. 

Just some thoughts.

-Bill

--- Brian Rice <water at tunes.org> 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
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 




More information about the Slate mailing list