librelist archives

« back to archive

import

import

From:
Kc Erb
Date:
2013-12-05 @ 19:18
Hi again,

When I run the following:

https://gist.github.com/KCErb/7811472

I get this error:

ArgumentError: wrong number of arguments calling `import` (1 for 0)
        import at

file:/Library/Frameworks/JRuby.framework/Versions/1.7.4/lib/jruby.jar!/jruby/java/core_ext/module.rb:53


So that made me think import is already defined and I used inspect to find
out:

Shoes.app do
  alert import.inspect
end

 And the alerted message was [], which tells me that it's not defined,
right?

But then I did a search on github and found the import method being used in
a few places (usually import org.eclipse.swt. . . ).

So essentially the answer to my question is: call your method something
besides import.

My next question is: is there a better way than guess and check to figure
out which methods are already defined? I thought that methods not included
in the DSL or my gems were free game. Any advice?

Thanks again,

KC


 "If there is an exception to every rule, then every rule must have at
least one exception; the exception to this one being that it has no
exception."




 "If there is an exception to every rule, then every rule must have at
least one exception; the exception to this one being that it has no
exception."

Re: [shoes] import

From:
Eric Watson
Date:
2013-12-06 @ 19:41
On Dec 5, 2013, at 1:18 PM, KC Erb <iamkcerb@gmail.com> wrote:

> Hi again,
> 
> When I run the following:
> 
> https://gist.github.com/KCErb/7811472
> 
> I get this error:
> 
> ArgumentError: wrong number of arguments calling `import` (1 for 0)
>         import at 
file:/Library/Frameworks/JRuby.framework/Versions/1.7.4/lib/jruby.jar!/jruby/java/core_ext/module.rb:53
> 

I can run that gist with no error on OS X 10.9

dingo:shoes4 eric$ jruby --version
jruby 1.7.8 (1.9.3p392) 2013-11-14 0ce429e on Java HotSpot(TM) 64-Bit 
Server VM 1.7.0_45-b18 [darwin-x86_64]

> So that made me think import is already defined and I used inspect to find out:
> 
> Shoes.app do
>   alert import.inspect
> end
> 
> And the alerted message was [], which tells me that it's not defined, right?

No, that tells you that it *is* defined, and that it returns an empty 
array. If it wasn’t defined, you would get a NameError. Like this:

jruby-1.7.8 :001 > import
 => []
jruby-1.7.8 :002 > bogus
NameError: undefined local variable or method `bogus' for #<Object:0x18b705e7>
	from (irb):2:in `evaluate'
	from org/jruby/RubyKernel.java:1123:in `eval'
	from org/jruby/RubyKernel.java:1519:in `loop'
	from org/jruby/RubyKernel.java:1284:in `catch'
	from org/jruby/RubyKernel.java:1284:in `catch'
	from /Users/eric/.rvm/rubies/jruby-1.7.8/bin/irb:13:in `(root)'


> But then I did a search on github and found the import method being used
in a few places (usually import org.eclipse.swt. . . ). 
> 
> So essentially the answer to my question is: call your method something 
besides import.
> 
> My next question is: is there a better way than guess and check to 
figure out which methods are already defined? I thought that methods not 
included in the DSL or my gems were free game. Any advice?

Even though your app isn’t failing for this reason, it could…Shoes 3 was 
very safe in this regard, but Shoes 4 isn’t yet. And there isn’t a way to 
know it except by trial and error. Or by inspecting the code of 
Shoes::App, where DSL code is eval’d. Basically, you can’t use any methods
or instance variables of Shoes::App. But we need to fix this.

I’ve created an issue with an example of how this can go bad here:

https://github.com/shoes/shoes4/issues/492


Cheers!

Eric

Re: [shoes] import

From:
Kc Erb
Date:
2013-12-06 @ 20:03
Thanks for the answer Eric,

It looks like so far I've contributed more issues than solutions so far,
I'll pretend like that's a good thing :)

I am on OS X 10.6.8, and I recently noted another interesting difference
between the platforms. If this cues any red flags for you professionals
then I'll be glad I shared it, otherwise I'm OK with it just being an
unimportant FYI.

One of the issues I'm debugging right now in converting my (fully
operational in Shoes3) app over to Shoes4 is that in Shoes4 it eats up tons
of memory and dies (~130MB per second until crash).

While trying to find the source of this, I noticed that my Shoes3 version
of the app does the same (eat RAM) but much more slowly (~.3 MB per second).

When I was discussing this issue with a friend of mine who uses the app on
his OS X 10.9 machine, we checked his Activity Monitor and were surprised
to find that it had no creeping memory issue (i.e. once the app was loaded
its Real Memory usage was stable as measured in Activity Monitor).

I don't know what to make of it, and I haven't figured out what's causing
it, but OS X 10.9 running Shoes3 doesn't repeat the error.

-KC


On Fri, Dec 6, 2013 at 12:41 PM, Eric Watson <wasnotrice@gmail.com> wrote:

>
> On Dec 5, 2013, at 1:18 PM, KC Erb <iamkcerb@gmail.com> wrote:
>
> > Hi again,
> >
> > When I run the following:
> >
> > https://gist.github.com/KCErb/7811472
> >
> > I get this error:
> >
> > ArgumentError: wrong number of arguments calling `import` (1 for 0)
> >         import at
> 
file:/Library/Frameworks/JRuby.framework/Versions/1.7.4/lib/jruby.jar!/jruby/java/core_ext/module.rb:53
> >
>
> I can run that gist with no error on OS X 10.9
>
> dingo:shoes4 eric$ jruby --version
> jruby 1.7.8 (1.9.3p392) 2013-11-14 0ce429e on Java HotSpot(TM) 64-Bit
> Server VM 1.7.0_45-b18 [darwin-x86_64]
>
> > So that made me think import is already defined and I used inspect to
> find out:
> >
> > Shoes.app do
> >   alert import.inspect
> > end
> >
> > And the alerted message was [], which tells me that it's not defined,
> right?
>
> No, that tells you that it *is* defined, and that it returns an empty
> array. If it wasn’t defined, you would get a NameError. Like this:
>
> jruby-1.7.8 :001 > import
>  => []
> jruby-1.7.8 :002 > bogus
> NameError: undefined local variable or method `bogus' for
> #<Object:0x18b705e7>
>         from (irb):2:in `evaluate'
>         from org/jruby/RubyKernel.java:1123:in `eval'
>         from org/jruby/RubyKernel.java:1519:in `loop'
>         from org/jruby/RubyKernel.java:1284:in `catch'
>         from org/jruby/RubyKernel.java:1284:in `catch'
>         from /Users/eric/.rvm/rubies/jruby-1.7.8/bin/irb:13:in `(root)'
>
>
> > But then I did a search on github and found the import method being used
> in a few places (usually import org.eclipse.swt. . . ).
> >
> > So essentially the answer to my question is: call your method something
> besides import.
> >
> > My next question is: is there a better way than guess and check to
> figure out which methods are already defined? I thought that methods not
> included in the DSL or my gems were free game. Any advice?
>
> Even though your app isn’t failing for this reason, it could…Shoes 3 was
> very safe in this regard, but Shoes 4 isn’t yet. And there isn’t a way to
> know it except by trial and error. Or by inspecting the code of Shoes::App,
> where DSL code is eval’d. Basically, you can’t use any methods or instance
> variables of Shoes::App. But we need to fix this.
>
> I’ve created an issue with an example of how this can go bad here:
>
> https://github.com/shoes/shoes4/issues/492
>
>
> Cheers!
>
> Eric
>
>


-- 
 "If there is an exception to every rule, then every rule must have at
least one exception; the exception to this one being that it has no
exception."

Re: [shoes] import

From:
Tobias Pfeiffer
Date:
2013-12-06 @ 20:42
On 12/06/2013 09:03 PM, KC Erb wrote:
> It looks like so far I've contributed more issues than solutions so
> far, I'll pretend like that's a good thing :)
This is a good thing. We can not fix issues, we do not know about. :-)
So thanks!

> One of the issues I'm debugging right now in converting my (fully 
> operational in Shoes3) app over to Shoes4 is that in Shoes4 it eats
> up tons of memory and dies (~130MB per second until crash).

It'd be interesting to see that app. That is indeed troubling. It
might be that we're not freeing/derefing all elements correctly. This
is still pre alpha software after all :-)

I tried a few samples, with some of them memory consumption grew
considerably at first but then basically maxed out at a certain point.

Cheers and thanks for your contributions! =)

Tobi


> 
> 
> On Fri, Dec 6, 2013 at 12:41 PM, Eric Watson <wasnotrice@gmail.com>
> wrote:
> 
>> 
>> On Dec 5, 2013, at 1:18 PM, KC Erb <iamkcerb@gmail.com> wrote:
>> 
>>> Hi again,
>>> 
>>> When I run the following:
>>> 
>>> https://gist.github.com/KCErb/7811472
>>> 
>>> I get this error:
>>> 
>>> ArgumentError: wrong number of arguments calling `import` (1
>>> for 0) import at
>> 
file:/Library/Frameworks/JRuby.framework/Versions/1.7.4/lib/jruby.jar!/jruby/java/core_ext/module.rb:53
>>>
>>
>>
>> 
I can run that gist with no error on OS X 10.9
>> 
>> dingo:shoes4 eric$ jruby --version jruby 1.7.8 (1.9.3p392)
>> 2013-11-14 0ce429e on Java HotSpot(TM) 64-Bit Server VM
>> 1.7.0_45-b18 [darwin-x86_64]
>> 
>>> So that made me think import is already defined and I used
>>> inspect to
>> find out:
>>> 
>>> Shoes.app do alert import.inspect end
>>> 
>>> And the alerted message was [], which tells me that it's not
>>> defined,
>> right?
>> 
>> No, that tells you that it *is* defined, and that it returns an
>> empty array. If it wasn’t defined, you would get a NameError.
>> Like this:
>> 
>> jruby-1.7.8 :001 > import => [] jruby-1.7.8 :002 > bogus 
>> NameError: undefined local variable or method `bogus' for 
>> #<Object:0x18b705e7> from (irb):2:in `evaluate' from
>> org/jruby/RubyKernel.java:1123:in `eval' from
>> org/jruby/RubyKernel.java:1519:in `loop' from
>> org/jruby/RubyKernel.java:1284:in `catch' from
>> org/jruby/RubyKernel.java:1284:in `catch' from
>> /Users/eric/.rvm/rubies/jruby-1.7.8/bin/irb:13:in `(root)'
>> 
>> 
>>> But then I did a search on github and found the import method
>>> being used
>> in a few places (usually import org.eclipse.swt. . . ).
>>> 
>>> So essentially the answer to my question is: call your method
>>> something
>> besides import.
>>> 
>>> My next question is: is there a better way than guess and check
>>> to
>> figure out which methods are already defined? I thought that
>> methods not included in the DSL or my gems were free game. Any
>> advice?
>> 
>> Even though your app isn’t failing for this reason, it
>> could…Shoes 3 was very safe in this regard, but Shoes 4 isn’t
>> yet. And there isn’t a way to know it except by trial and error.
>> Or by inspecting the code of Shoes::App, where DSL code is
>> eval’d. Basically, you can’t use any methods or instance 
>> variables of Shoes::App. But we need to fix this.
>> 
>> I’ve created an issue with an example of how this can go bad
>> here:
>> 
>> https://github.com/shoes/shoes4/issues/492
>> 
>> 
>> Cheers!
>> 
>> Eric
>> 
>> 
> 
> 

Re: [shoes] import

From:
Kc Erb
Date:
2013-12-08 @ 15:15
Once I get this thing over to Shoes4 I will definitely have it up on
github. The only reason it's not there right now is that I'm using about 9
gems in my app and almost every one of them required me to edit their
source code and the Shoes3 source (gasp!) to get them to work.

In other words I'm on an island. But once I get off, if I still have this
memory issue, I'll share it for sure.

On that point, if you think it'd be useful I could put the current (broken)
shoes4 version in a repo for y'all to look at but I warn you, it's very
non-ruby (I had a kind rubyist point that out to me and he is now helping
me restructure / teaching me how to program).

Thanks for the encouragement and help!

-KC


On Fri, Dec 6, 2013 at 1:42 PM, Tobias Pfeiffer <
tobias.pfeiffer@student.hpi.uni-potsdam.de> wrote:

> On 12/06/2013 09:03 PM, KC Erb wrote:
> > It looks like so far I've contributed more issues than solutions so
> > far, I'll pretend like that's a good thing :)
> This is a good thing. We can not fix issues, we do not know about. :-)
> So thanks!
>
> > One of the issues I'm debugging right now in converting my (fully
> > operational in Shoes3) app over to Shoes4 is that in Shoes4 it eats
> > up tons of memory and dies (~130MB per second until crash).
>
> It'd be interesting to see that app. That is indeed troubling. It
> might be that we're not freeing/derefing all elements correctly. This
> is still pre alpha software after all :-)
>
> I tried a few samples, with some of them memory consumption grew
> considerably at first but then basically maxed out at a certain point.
>
> Cheers and thanks for your contributions! =)
>
> Tobi
>
>
> >
> >
> > On Fri, Dec 6, 2013 at 12:41 PM, Eric Watson <wasnotrice@gmail.com>
> > wrote:
> >
> >>
> >> On Dec 5, 2013, at 1:18 PM, KC Erb <iamkcerb@gmail.com> wrote:
> >>
> >>> Hi again,
> >>>
> >>> When I run the following:
> >>>
> >>> https://gist.github.com/KCErb/7811472
> >>>
> >>> I get this error:
> >>>
> >>> ArgumentError: wrong number of arguments calling `import` (1
> >>> for 0) import at
> >>
> 
file:/Library/Frameworks/JRuby.framework/Versions/1.7.4/lib/jruby.jar!/jruby/java/core_ext/module.rb:53
> >>>
> >>
> >>
> >>
> I can run that gist with no error on OS X 10.9
> >>
> >> dingo:shoes4 eric$ jruby --version jruby 1.7.8 (1.9.3p392)
> >> 2013-11-14 0ce429e on Java HotSpot(TM) 64-Bit Server VM
> >> 1.7.0_45-b18 [darwin-x86_64]
> >>
> >>> So that made me think import is already defined and I used
> >>> inspect to
> >> find out:
> >>>
> >>> Shoes.app do alert import.inspect end
> >>>
> >>> And the alerted message was [], which tells me that it's not
> >>> defined,
> >> right?
> >>
> >> No, that tells you that it *is* defined, and that it returns an
> >> empty array. If it wasn’t defined, you would get a NameError.
> >> Like this:
> >>
> >> jruby-1.7.8 :001 > import => [] jruby-1.7.8 :002 > bogus
> >> NameError: undefined local variable or method `bogus' for
> >> #<Object:0x18b705e7> from (irb):2:in `evaluate' from
> >> org/jruby/RubyKernel.java:1123:in `eval' from
> >> org/jruby/RubyKernel.java:1519:in `loop' from
> >> org/jruby/RubyKernel.java:1284:in `catch' from
> >> org/jruby/RubyKernel.java:1284:in `catch' from
> >> /Users/eric/.rvm/rubies/jruby-1.7.8/bin/irb:13:in `(root)'
> >>
> >>
> >>> But then I did a search on github and found the import method
> >>> being used
> >> in a few places (usually import org.eclipse.swt. . . ).
> >>>
> >>> So essentially the answer to my question is: call your method
> >>> something
> >> besides import.
> >>>
> >>> My next question is: is there a better way than guess and check
> >>> to
> >> figure out which methods are already defined? I thought that
> >> methods not included in the DSL or my gems were free game. Any
> >> advice?
> >>
> >> Even though your app isn’t failing for this reason, it
> >> could…Shoes 3 was very safe in this regard, but Shoes 4 isn’t
> >> yet. And there isn’t a way to know it except by trial and error.
> >> Or by inspecting the code of Shoes::App, where DSL code is
> >> eval’d. Basically, you can’t use any methods or instance
> >> variables of Shoes::App. But we need to fix this.
> >>
> >> I’ve created an issue with an example of how this can go bad
> >> here:
> >>
> >> https://github.com/shoes/shoes4/issues/492
> >>
> >>
> >> Cheers!
> >>
> >> Eric
> >>
> >>
> >
> >
>



-- 
 "If there is an exception to every rule, then every rule must have at
least one exception; the exception to this one being that it has no
exception."

Re: [shoes] import

From:
Eric Watson
Date:
2013-12-08 @ 16:14
On Dec 6, 2013, at 2:42 PM, Tobias Pfeiffer 
<tobias.pfeiffer@student.hpi.uni-potsdam.de> wrote:

> On 12/06/2013 09:03 PM, KC Erb wrote:
> 
>> One of the issues I'm debugging right now in converting my (fully 
>> operational in Shoes3) app over to Shoes4 is that in Shoes4 it eats
>> up tons of memory and dies (~130MB per second until crash).
> 
> It'd be interesting to see that app. That is indeed troubling. It
> might be that we're not freeing/derefing all elements correctly. This
> is still pre alpha software after all :-)
> 
> I tried a few samples, with some of them memory consumption grew
> considerably at first but then basically maxed out at a certain point.
> 

This has been my observation:

Shoes 3: RAM usage grows slowly over time, but CPU is steady and small
Shoes 4: RAM usage is moderate and steady, but CPU is high

So we’d love to be able to play with your app and track down why it crashes Shoes.

Eric