Redefining If

I had time today to sit on several Brail bugs. I keep getting more and more and more amazed by the power that Boo is giving me.

In order to fix some of those bugs, I had to literally change the meaning of the if statement. (I defined my own nullable propagator, which I had to implement deeply into the language).

Damn, I love this language.

Oh, and FYI, if 2+2 == 4 will not do the expected thing anymore :-) 

Print | posted on Thursday, October 04, 2007 8:37 PM

Feedback


Gravatar

# re: Redefining If 10/4/2007 9:49 PM Avish

How did you redefine if? A custom compiler step?


Gravatar

# re: Redefining If 10/4/2007 9:51 PM Ayende Rahien

Yeah, fairly amazing.
https://svn.castleproject.org/svn/castle/trunk/MonoRail/
Castle.MonoRail.Views.Brail/FixTryGetParameterConditionalChecks.cs

Basically, transform "if ?Errors" to "if not TryGetParameter("Errors") isa IgnoreNull"


Gravatar

# re: Redefining If 10/4/2007 10:38 PM Steven Harman

> if 2+2 == 4 will not do the expected thing anymore

And what about the Principle of Least Surprise... breaking your own rules, eh? :)


Gravatar

# re: Redefining If 10/4/2007 11:20 PM Miles Thompson

Ayende,

I worship you like a god (small G) but.. seriously 'redefining if'.. argh, sounds much more like something one would read at the daily wtf (worsethanfailure.com) than here..


Gravatar

# re: Redefining If 10/4/2007 11:26 PM Ayende Rahien

Steven,
_that_ was a joke, I am afraid.


Gravatar

# re: Redefining If 10/4/2007 11:30 PM Ayende Rahien

Moles,
Oh, then I guess I shouldn't tell when I did to the goto statement, then :-D


Gravatar

# re: Redefining If 10/4/2007 11:38 PM Steven Harman

Haha... my bad. I guess my sarcasm didn't quite come across... I seem to have trouble with that when it comes to written communication. I supposed I could have used a little markup to help.

<sarcasm> insert snarky comment here </sarcasm>

:)


Gravatar

# re: Redefining If 10/5/2007 2:30 AM Avish

Uhm, maybe I'm not reading it right, but wouldn't it be easier to make your null object equal to null by overriding Equals()? then you'd still be able to do "if ?Errors" etc. What am I missing?


Gravatar

# re: Redefining If 10/5/2007 2:38 AM Ayende Rahien

It would be easier, but Boo emits an op_Equality test, and since we are dealing with duck typing here, it will not note the user defined op_Equality or the Equals() override

Comments have been closed on this topic.