librelist archives

« back to archive

Bug or upgrade?

Bug or upgrade?

From:
ashbb
Date:
2010-07-11 @ 14:22
Hi all,

I've started checking Shoes built-in manual for Policeman. :)
Then I have a question.
Look at the following snippet and the manual,
Hello!/Rulues/The Main App and Its Requires.

http://shoes.heroku.com/manual/Rules.html

  main = self
  Shoes.app do
    para main.to_s
  end

With Raisins (0.r1134), the output is `(shoes)`.
With Policeman (0.r1469), the output is `main`.

Umm... is this a bug or upgrade?

ashbb

Re: [shoes] Bug or upgrade?

From:
Devyn Cairns
Date:
2010-07-11 @ 21:01
It should be 'main'. If it's (shoes), that's a bug.

On Sun, Jul 11, 2010 at 7:22 AM, ashbb <ashbbb@gmail.com> wrote:

> Hi all,
>
> I've started checking Shoes built-in manual for Policeman. :)
> Then I have a question.
> Look at the following snippet and the manual,
> Hello!/Rulues/The Main App and Its Requires.
>
> http://shoes.heroku.com/manual/Rules.html
>
>   main = self
>   Shoes.app do
>     para main.to_s
>   end
>
> With Raisins (0.r1134), the output is `(shoes)`.
> With Policeman (0.r1469), the output is `main`.
>
> Umm... is this a bug or upgrade?
>
> ashbb
>



-- 
    ~devyn

Re: [shoes] Bug or upgrade?

From:
ashbb
Date:
2010-07-11 @ 21:13
devyn,

The output `(shoes)` is not a bug at least in Raisins. ;-)

Please read `The Main App and Its Requires`:
http://shoes.heroku.com/manual/Rules.html

_why wrote about that explicitly.

So, I'm stll wondering...

ashbb

Re: [shoes] Bug or upgrade?

From:
Devyn Cairns
Date:
2010-07-11 @ 21:23
Oh, okay, I see. Hmm.

On Sun, Jul 11, 2010 at 2:13 PM, ashbb <ashbbb@gmail.com> wrote:

> devyn,
>
> The output `(shoes)` is not a bug at least in Raisins. ;-)
>
> Please read `The Main App and Its Requires`:
>
> http://shoes.heroku.com/manual/Rules.html
>
> _why wrote about that explicitly.
>
> So, I'm stll wondering...
>
> ashbb
>



-- 
    ~devyn

Re: [shoes] Bug or upgrade?

From:
Steve Klabnik
Date:
2010-07-11 @ 15:26
I am not sure.

I did this:

$ rvm use 1.9.1

$ irb

ruby-1.9.1-p378 > main = self

 => #<Object:0x000001008b8e58 @prompt={:PROMPT_I=>"ruby-1.9.1-p378 > ",
> :PROMPT_S=>"ruby-1.9.1-p378%l> ", :PROMPT_C=>"ruby-1.9.1-p378 > ",
> :PROMPT_N=>"ruby-1.9.1-p378 ?> ", :RETURN=>" => %s \n",
> :AUTO_INDENT=>true}>

ruby-1.9.1-p378 > func = Proc.new { puts main.to_s; }

 => #<Proc:0x000001009dd728@(irb):2 (lambda)>

ruby-1.9.1-p378 > func.call

main

 => nil

$ rvm use 1.8.7

$ irb

ruby-1.8.7-p249 > main = self

 => #<Object:0x1001bd298 @prompt={:AUTO_INDENT=>true, :RETURN=>" => %s \n",
> :PROMPT_I=>"ruby-1.8.7-p249 > ", :PROMPT_N=>"ruby-1.8.7-p249 ?> ",
> :PROMPT_S=>"ruby-1.8.7-p249%l> ", :PROMPT_C=>"ruby-1.8.7-p249 > "}>

ruby-1.8.7-p249 > func = Proc.new { puts main.to_s }

 => #<Proc:0x0000000100454678@(irb):2>

ruby-1.8.7-p249 > func.call

main

 => nil


I am not 100% sure if this is even exactly relevant, just a quick check. I'm
not 100% great with 'self' and all those various shenanigans yet...

I'm leaning towards 'upgrade', though.

On Sun, Jul 11, 2010 at 10:22 AM, ashbb <ashbbb@gmail.com> wrote:

> Hi all,
>
> I've started checking Shoes built-in manual for Policeman. :)
> Then I have a question.
> Look at the following snippet and the manual,
> Hello!/Rulues/The Main App and Its Requires.
>
> http://shoes.heroku.com/manual/Rules.html
>
>   main = self
>   Shoes.app do
>     para main.to_s
>   end
>
> With Raisins (0.r1134), the output is `(shoes)`.
> With Policeman (0.r1469), the output is `main`.
>
> Umm... is this a bug or upgrade?
>
> ashbb
>

Re: [shoes] Bug or upgrade?

From:
ccoupe@cableone.net
Date:
2010-07-12 @ 09:19
The referenced article explains why Shoes is not Ruby, it only *looks* 
like it.<BR>
<BR>
I say it's a bug in the 1.9.1 code. Or does the documentation not reflect 
what is in Policeman. It might effect Shoes programs that use multiple 
windows or require external scripts (Widgets).<BR>
<BR>
OSX and Linux users should run the script the ashbb/_why provided. Is it 
'main' or '(shoes)'.  Either the doc or code has to be modified so 
they match.<BR>
<BR>
 <BR>
<BR>
<span style="font-weight: bold;">On Sun Jul 11 15:13 , ashbb 
<ashbbb@gmail.com> sent:<BR>
<BR>
</ashbbb@gmail.com></span><blockquote style="border-left: 2px solid 
rgb(245, 245, 245); margin-left: 5px; margin-right: 0px; padding-left: 
5px; padding-right: 0px;">devyn,<BR>
<BR>
The output `(shoes)` is not a bug at least in Raisins. ;-)<BR>
<BR>
Please read `The Main App and Its Requires`:<BR>
<a target="_blank" 
href="http://shoes.heroku.com/manual/Rules.html">http://shoes.heroku.com/manual/Rules.html</a><BR>

<BR>
_why wrote about that explicitly.<BR>
<BR>
So, I'm stll wondering...<BR>
<BR>
ashbb<BR>

</blockquote><BR><hr>Msg sent via CableONE.net MyMail - http://www.cableone.net

Re: [shoes] Bug or upgrade?

From:
ashbb
Date:
2010-07-13 @ 12:40
Thank you for discussions.

Finally, I guess this is the upgrade. :)

Raisins uses Shoes.anonymous_binding like this:
http://github.com/ashbb/shoes_hack_note/blob/master/md/hack001.md

Policeman uses TOPLEVEL_BINDING like this:
http://github.com/shoes/shoes/blob/master/lib/shoes.rb#L405

Look at the following two cases.

1st:

    a = Para
    Shoes.app do
      para a
      para Para
    end

With Raisins, it works and shows `Shoes::Para Shoes::Para`.
But with Policeman, error happens `Uninitialized Constants Para` at first
line.
If you comment out first and third lines, it works and shows `Shoes::Para`.
Or if you use `a = Shoes::Para`, it works fine.
This is because Policeman is using TOPLEVEL_BINDING.

2nd:

    class Strange; end
    Shoes.app do
      para Strange.new
    end

Raisins shows `(#<Class::0x15a499c>::Strange)`.
Policeman shows `(Strange)`.
There is a little difference but not matter, I think.
But,...

    # shoes_app.rb
    Shoes.app do
      para Strange.new
    end

    # test.rb
    class Strange; end
    require 'shoes_app'

If you run test.rb with Policeman, it works and shows `(Strange)`.
With Raisins, error happens `Uninitialized Constants Strange` at line 3 of
shoes_app.rb file.

Conclusion:
I guess the last rule of `The Main App and Its Requires` in built-in manual:
"keep your temporary classes in the code with the app and keep your
permanent classes in requires." is no need for Policeman. :)

What do you think?

ashbb