Idiom wanted (now hiring!)

That might be to my liking too if there were not

···

On 4/14/07, Christian Neukirchen <chneukirchen@gmail.com> wrote:

"Robert Dober" <robert.dober@gmail.com> writes:

> On 4/13/07, Nobuyoshi Nakada <nobu@ruby-lang.org> wrote:
>> Hi,
>>
>> At Fri, 13 Apr 2007 17:57:47 +0900,
>> Robert Dober wrote in [ruby-talk:247783]:
>> > > a = func(b) || a
>> > and if a did not exist before?
>>
>> a does exist at the assignment and initialized as nil.
>>
>> --
>> Nobu Nakada
>>
> Thx Nobu, that is as a matter of fact a "logical" and "functional"
> explanation, but my question was rather conceptional.
> Do make it clear I will be a little bit blunt, forgive me.
> I do not like that behavior!
> And you ?

It's very philosophical:

$ ruby -e 'thing = thing; p thing'
nil

======================
501/1 > ruby -e '@x=@x;p @x'
nil
--------------------------->
503/3 > ruby -e 'p @x'
nil

504/4 > ruby -e 'x=x;p x'
nil
-------------------------->
505/5 > ruby -e 'p x'
-e:1: undefined local variable or method `x' for main:Object (NameError)

You see it is not the isolated semantics of x=x, but the context of
other semantics that disturbs me (well disturbs me just a tiny little
bit ;).

Cheers
Robert

--
Christian Neukirchen <chneukirchen@gmail.com> http://chneukirchen.org

I know. I was one of them >;o

Ellie

Eleanor McHugh
Games With Brains

···

On 13 Apr 2007, at 14:37, Robert Dober wrote:

On 4/13/07, Eleanor McHugh <eleanor@games-with-brains.com> wrote:

On 13 Apr 2007, at 13:29, Robert Dober wrote:
> a = x if x
> is kind of *not*
> a ||=x

I suspect we've all made that mistake at one time or another :wink:

Really nice of you to say so, but to be honest, 99.99999% of the
people having made that mistake wisely refused to send it to the ML :wink:

----
raise ArgumentError unless @reality.responds_to? :reason

"Robert Dober" <robert.dober@gmail.com> writes:

You see it is not the isolated semantics of x=x, but the context of
other semantics that disturbs me (well disturbs me just a tiny little
bit ;).

So you are proposing all undefined locals return nil too? }}:slight_smile:

···

--
Christian Neukirchen <chneukirchen@gmail.com> http://chneukirchen.org

"Robert Dober" <robert.dober@gmail.com> writes:

> You see it is not the isolated semantics of x=x, but the context of
> other semantics that disturbs me (well disturbs me just a tiny little
> bit ;).

So you are proposing all undefined locals return nil too? }}:slight_smile:

No I am too young to die, because that means we need python call syntax
for the implicit receiver, maybe you want some parens too ;).
Beware I am writing this in the best intent.
Ok fooled around enough.

The real problem is the implicit declaration of variables of course.
I feel that it should be hidden which means it should take place after
the RHS evaluation, but in practice it takes place before.

Well I can life with that :slight_smile:

Cheers
Robert

···

On 4/14/07, Christian Neukirchen <chneukirchen@gmail.com> wrote:

--
Christian Neukirchen <chneukirchen@gmail.com> http://chneukirchen.org

--
You see things; and you say Why?
But I dream things that never were; and I say Why not?
-- George Bernard Shaw

Perhaps Kernel.variable_missing?
Or I'm just crazy...

···

On Apr 14, 10:49 am, Christian Neukirchen <chneukirc...@gmail.com> wrote:

"Robert Dober" <robert.do...@gmail.com> writes:
> You see it is not the isolated semantics of x=x, but the context of
> other semantics that disturbs me (well disturbs me just a tiny little
> bit ;).

So you are proposing all undefined locals return nil too? }}:slight_smile:

--
Christian Neukirchen <chneukirc...@gmail.com> http://chneukirchen.org

"Robert Dober" <robert.dober@gmail.com> writes:

"Robert Dober" <robert.dober@gmail.com> writes:

> You see it is not the isolated semantics of x=x, but the context of
> other semantics that disturbs me (well disturbs me just a tiny little
> bit ;).

So you are proposing all undefined locals return nil too? }}:slight_smile:

No I am too young to die, because that means we need python call syntax
for the implicit receiver, maybe you want some parens too ;).
Beware I am writing this in the best intent.
Ok fooled around enough.

The real problem is the implicit declaration of variables of course.
I feel that it should be hidden which means it should take place after
the RHS evaluation, but in practice it takes place before.

Well I can life with that :slight_smile:

In my five years of using Ruby, this has bitten me maybe twice.

I think I misspelled "initialize" a lot more. :stuck_out_tongue:

···

On 4/14/07, Christian Neukirchen <chneukirchen@gmail.com> wrote:

Cheers
Robert

--
Christian Neukirchen <chneukirchen@gmail.com> http://chneukirchen.org

> "Robert Dober" <robert.do...@gmail.com> writes:
> > You see it is not the isolated semantics of x=x, but the context of
> > other semantics that disturbs me (well disturbs me just a tiny little
> > bit ;).
>
> So you are proposing all undefined locals return nil too? }}:slight_smile:
>
> --
> Christian Neukirchen <chneukirc...@gmail.com> http://chneukirchen.org

Perhaps Kernel.variable_missing?
Or I'm just crazy...

I hope not ;), but I think this will enter in conflict with method_missing.

Robert

···

On 4/15/07, CHubas <CHubas7@gmail.com> wrote:

On Apr 14, 10:49 am, Christian Neukirchen <chneukirc...@gmail.com> > wrote:

--
You see things; and you say Why?
But I dream things that never were; and I say Why not?
-- George Bernard Shaw

<snip>

I think I misspelled "initialize" a lot more. :stuck_out_tongue:

That for sure, that was a great PITN at first!!

> Cheers
> Robert
--
Christian Neukirchen <chneukirchen@gmail.com> http://chneukirchen.org

Robert

···

On 4/15/07, Christian Neukirchen <chneukirchen@gmail.com> wrote:

--
You see things; and you say Why?
But I dream things that never were; and I say Why not?
-- George Bernard Shaw

> > So you are proposing all undefined locals return nil too? }}:slight_smile:

> Perhaps Kernel.variable_missing?
> Or I'm just crazy...

I hope not ;), but I think this will enter in conflict with method_missing.

Robert

I think it's not a preposterous (translation dictionaries are silly)
idea after all, if handled well. Say, method_missing would have more
precedence than variable_missing.

As for now, method missing is worth a try

def method_missing
  nil
end

foo
=> nil
x ||= 10
=> 10
x
=> 10

but this is obviously wicked. Specially with typos and lexical
mistakes. I think it's worse to get bad results from bad valued than
get an error and make things right instead.

Oh, and it doesn't handle constants.

FOO
=> NameError: uninitialized constant OK
        from (irb):32

···

On Apr 15, 3:28 pm, "Robert Dober" <robert.do...@gmail.com> wrote:
        from :0