In article <pan.2002.09.13.18.54.31.523405.2402 / nc.rr.com>,
Tim Hunter  <cyclists / nc.rr.com> wrote:
>Other folks have already answered the general version of this question much more
>authoritatively and eloquently than I can.Somewhere later on in this thread,
>Patrick May says "Conditionals on type are a smell of code that could
>be moved from the users of a class to the class itself." I agree, and
>you've already hinted at part of a solution: add a method to Signal that
>does the proc{function.to_s}.call. Add a similarly named method to Proc
>(or a subclass of Proc and then require the argument to be an object of
>the subclass).
>
>That doesn't help for Fixnum or nil arguments, though. Here I gotta tell
>ya, this makes me think it's time for some refactoring. Since "function"
>can be any of 4 wildly different things, I wonder if assign_at is doing
>the work of more than one method. Just thinking out loud, you
>understand.
>

Oh, I definately understand what you're saying and under a different set 
of constraints I would do just that (refactor).  It's just that the goal 
here is to basically make Ruby look like another programming language 
(technically an HDL [Hardware Description Language]).  I don't want users 
to have to remember that there are several different assign methods 
for Signals,  like: assign_signal, assign_Fixnum, assign_function or 
assign_proc.  These are details they really don't care to know.  So I'm 
trying to help out the users in this case who will be coming from an 
HDL like VHDL or Verilog (and these are generally hardware engineers) so 
RHDL doesn't seem too foreign to them.

I think it was Joel V. who said in a recent post that Ruby's procs are 
great for creating little languages that are appropriate for certain 
domains - that's pretty much what I've done with RHDL.

>Lastly, I admit I'm not smart enough to have thought of Phillip's
>approach. But you know, that hash looks like it's sending methods based
>on an object's type, and Ruby will do that for us anyway if we ask it.
>

I need to look deeper at his approach, but my first impression was that 
it wasn't what I'm looking for.


Phil