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 ?
> 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? }}
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
Cheers
Robert
···
On 4/14/07, Christian Neukirchen <chneukirchen@gmail.com> wrote:
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? }}
> 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? }}
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
In my five years of using Ruby, this has bitten me maybe twice.
I think I misspelled "initialize" a lot more.
···
On 4/14/07, Christian Neukirchen <chneukirchen@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? }}
>
> --
> 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
> > So you are proposing all undefined locals return nil too? }}
> 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