Hello,
– Nikodemus suggested:
The symbols as lvalues idea
:m = x
I agree about the aroma. What about the sound of it:
“assign x to my m"
or
"assign x to m, which is a local variable”
?
···
About Empowering Symbols, some idioms of mine (if I may):
Optional parameter that deal with nil well
def a( opt = :None )
case opt
when xxx
when yyy
when nil
when :None
end
end
Orderless optional parameters
def a( opt1 = :Default, opt2 = :Default )
opt1 = something1 if opt1 == :Default
opt2 = Something2 if opt1 == :Default
xxx
)
a()
a(my_thing)
a( :Default, my_thing)
Localization/Substitution/Skin/Style
def msg( x )
x = $MSG[x] || x.to_s()
xxx
end
if french? then
$MSG[:World] = "le Monde"
end
p msg( :Hello)
p msg( ", ")
p msg( :World)
Complex return values
def humm()
return :OK if xxx
return :Delayed if xx
return :nil if xxx
return xxx if xxx
return :Failure if xxx
end
class Kernel
def fail?( s ) s == :Failure end
def succeed?( s ) s != :Failure end
end
foo = v if succeed? v = obj.humm
Is there some repository of such “Styles” ?
BTW: My Ruby Source Code HTML pretty printer displays
table( :Width => “100”)
as
table( Width: “100”)
Yours,
Jean-Hugues
Web: http://hdl.handle.net/1030.37/1.1
Phone: +33 (0) 4 92 27 74 17