compile
thufir@arrakis:~/sun_tutorial$
thufir@arrakis:~/sun_tutorial$ cat compile.rb
def compile
system(echo compile)
end
thufir@arrakis:~/sun_tutorial$
thufir@arrakis:~/sun_tutorial$ ruby build.rb
./compile.rb:2: warning: parenthesize argument(s) for future version
./compile.rb:2:in compile': stack level too deep (SystemStackError) from ./compile.rb:2:incompile’
from build.rb:4
thufir@arrakis:~/sun_tutorial$
thufir@arrakis:~/sun_tutorial$
When you first call the ‘compile’ method, ruby tries to execute the line
system(echo compile)
which is interpreted as:
system(echo(compile))
Now ruby needs to evaluate the arguments to the system method. It sees a
single argument, that is the return value of the echo method called with
the
result of a call to the compile method. The first thing it needs to do
is get
the return value of the compile method. But the compile method calls the
compile method again, and so on, which causes infinite recursion and the
error
message you see.
A simpler example is this:
def my_method
my_method
end
Of course, this also cause an infinite recursion and a SystemStackError.
Back to your compile method. My guess is that you wanted to execute the
shell
command echo with argument ‘compile’. If this is true, you need to pass
a
string to system:
On Wed, 19 Mar 2008 20:13:43 +0900, Todd B. wrote:
I don’t know anything about compile. But with #system, I think you are
supposed to have the parameter in quotes.
Right now, your function is recursive with no exit.
Yes, I’m kinda sorry that I posted that question. It’s always like
that,
if I didn’t post it then I would’ve spent a long time figuring it out,
but if I post then I often get it fixed fairly quickly!
Please do comment on the “right” way to do this, keeping in mind that
it’s partly a way of learning ruby:
On Wed, 19 Mar 2008 20:10:09 +0900, Stefano C. wrote:
A simpler example is this:
def my_method
my_method
end
An interesting foray into recursion, I had no idea how to interpret that
error, but now have some idea
Keeping in mind that I’m a beginner ruby-ist, how should I go about
creating a manifest for a java jar? I believe there’s an “automatic”
option, but I’m not positive.
Does it make sense to create a text file from within ruby, then
“include”
that text file as the manifest when doing the jar command? Seems mildly
fragile. IIRC ant automagically takes care of the manifest, so perhaps
I’ll have to create something like that.
I know of raven, but prefer to do it this way for now, it’s a good
impetus to learn some ruby!
but if I post then I often get it fixed fairly quickly!
require ‘compile’
end
removed `HelloWorldApp.class’
thanks,
Thufir
Looks just fine.
I’m not sure, but if all your required files are to solely work with
cleaning and building code, then maybe they should sit inside a module
in one file.
Just a thought.
Obviously, every person has their own best way to approach it.
On Wed, 19 Mar 2008 20:49:51 +0900, Todd B. wrote:
Looks just fine.
I’m not sure, but if all your required files are to solely work with
cleaning and building code, then maybe they should sit inside a module
in one file.
Just a thought.
Obviously, every person has their own best way to approach it.
Thanks, that’s exactly the type of feedback I was soliciting!
-Thufir
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.