Do you want ":=" operator?

Phil Tomson wrote:

Indeed. I understand exactly, but I suspect there are about 3 of us

on

this list who have done hardware design (or used HDLs). I think

perhaps

we're having a hard time conveying what we're trying to do and how a

':='

operator could really help. Maybe we need to come up with a more

general use

for a ':=' operator that everyone can relate to. I'm sure some

examples exist.

I have an simple but nice example which was found when I prototyped
crypto algorithms.
Modular mathematics are common operations in public key encryption. Say
that "Zx" is a Class represents the group of integer [0,x-1], whose
math ops are modular reduction to x after do integer operation. e.g.
class Z31 # should implemented dynamically, just for sample
Modulus=31
def initialize(v=0)
@value=v.to_i % Modulus
end
def to_i
@value
end
def :=(v)
@value=v.to_i % Modulus
end
def +(v)
(@value+v) % Modulus
end
# .. some methods
end

c = Z31.new #=> 0
a = Z31.new(120) #=> 27
b = Z31.new(a) #=> 27

c := a #=> 27
c := a + b #=> 31
c := 100 #=> 7

Without ":=", you have to write "c=Z31.new(100)" whenever you want
assign an integer to a variable and Z31.+() must return a new Z31
object (I don't know whether this will affect the performance when
deals with Bignum). But we need no new objects indeed!
With ":=", you can write crypto algorithm programs in very clear and
natural way, which are just pseudo-codes in eyes of the person who
don't know ruby.