< :the previous in number
^ :the list in numerical order
> :the next in number
P :the previous aricle (the previous thread)
N :the next (in thread)
|<:the previous thread
>|:the next thread
^ :the parent (reply-to)
_:the child (an article replying to this)
>:the elder article having the same parent
<:the youger article having the same parent
---:split window and show thread lists
| :split window (vertically) and show thread lists
~ :close the thread frame
.:the index
..:the index of indices
In article <3E729E3F.7020007 / day-reynolds.com>,
Lennon Day-Reynolds <lennon / day-reynolds.com> wrote:
>Every variation I've tried of passing a block as a parameter to an
>operator fails with a syntax error, so at least on 1.6.8/Win32, there
>doesn't appear to be any syntactic support for what you're trying to do.
>Of course, you could just have the operator accept a Proc instance,
>rather than a bare block, as a parameter, at the cost of five extra
>characters for each call.
>
>
>Lennon
True, but...
1) I'm sort of creating a domain specific language from Ruby (an HDL) and
I'm trying to hide that sort of thing from the user.
2) I'm wondering if this is some sort of bug?
Phil
>
>Phil Tomson wrote:
>
>>I'm trying to define an operator that takes a block, like:
>>
>>a << {puts "Action!"}
>>
>>but the part in '{}' gets interpreted as a hash. Here's the sample code:
>>class Foo
>> def initialize(&proc)
>> @closure = proc
>> end
>>
>> def assign(newVal = Proc.new)
>> @closure = newVal
>> end
>>
>> def <<(newVal = Proc.new)
>> @closure = newVal
>> end
>> def callit
>> @closure.call
>> end
>>end
>>
>>f= Foo.new { puts "Action!" }
>>f.callit #=> "Action!"
>>f.assign { puts "New Action!" }
>>f.callit #=> "New Action!"
>>f<< { puts "Latest Action!" }
>>
>>SyntaxError: compile error
>>(irb):26: parse error
>>f << { puts "Latest Action!" }
>> ^
>> from (irb):26
>>
>>.... it seems as though the block being passed to '<<' is getting
>>interpreted as a hash while it isn't for the 'assign' method. Is there
>>anyway around this?
>>
>>
>>Phil
>>
>>
>>
>
>