adambillyard / googlemail.com wrote:
> Are there any guidelines for the operational semantics of assignment
> methods?  It seems that because its little more than syntactic sugar,
> its pretty adhoc.
> 
> While working with Ruby in Sketchup I came across a method to assign a
> texture to a material.  ie
> 
> myMaterial.texture= "filename_of_an_image"
> 
> Its meant to read an image file, create a "texture" object and assign
> it.
> 
> The behaviour appears to be that if the filename doesn't exist / can't
> be read, the property "texture" isn't changed.  My first reaction was
> that its just wrong but on reflection, if assignment methods are
> really just regular "set" style methods dressed up, then thats exactly
> the behaviour I would expect - or at least would think reasonable.
> 
> However, if it really *is* assignment, I'd expect myMaterial.texture
> to be nil after a reading of a non-existent filename.
> 
> Thoughts?
Yup, it's just setter sugar.  The method Material#texture= can do 
*anything*.  Whether it's a good idea to leave the property unchanged on 
failure, I don't know.  Neither way is guaranteed to be safe.

-- 
Alex