destructive! operations

A

Alexander Kellett

It shouldn't be in C. Such things should be in Ruby.

:(

I don't know C, so I can't learn Ruby?
So can't I know the behaviours of my changes?

in the current ruby implementation this
is the case. hopefully an alternative
implementation will be available eventually :)

(be it rubydium or ruby2c/metaruby)

Alex
 
D

David A. Black

Hi --

in the current ruby implementation this
is the case. hopefully an alternative
implementation will be available eventually :)

(be it rubydium or ruby2c/metaruby)

Although this raises the old question of what an "implementation of"
"Ruby" is....


David
 
A

Alexander Kellett

And that these are not necessarily easier to understand than the C
implementations...

depends on what part of the re-implementation you mean.
the whole, or the part that implements the languages features,
the core of both ruby2c and rubydium are likely to pretty dang
complex, simply because they do difficult things :)

otoh, the outer parts of the project, the things that users will
most likely want to look at to understand the ruby language from
the implementation, are likely to be much more readable than
there c counterparts.

of course. its damn good c code. it'll be a while till i personally
reach anything as readable as that. thats one limitation of having
only one coder :)

Alex
 
P

Pit Capitain

Navindra said:
Hehehe. Why? Is Florian known for pushing the frontier as to what it
is possible in Ruby?

Wouldn't be surprised... :)

Hi Navin, just look at the "evil" project on rubyforge and you know what I mean.

Regards,
Pit
 
L

Logan Capaldo

class NilClass
def method_missing(meth_id, *args); self; end
end

?

:)

ObjectiveC's nil works this way.

The downside is you don't find out as early when you
received an unexpected nil, in situations where you
would have preferred to be notified.

Regards,

Bill

Ooo, this just gave me an idea!

Block scope redefinitions of classes!

withImaginaryHungryNilConstruct do
while(line = gets.chomp )
# do stuff with line
end
end # here NilClasses's definition reverts back to normal

You could do this in Ruby now, the only problem being is it would have
dynamic and not lexical "scope" if I may obscenely misuse a term. This
could be quite useful, I imagine, especially if it was generic (eg.
have a way of saying use these modifications for class X for the
duration of this block).
 
A

Aredridel

Ooo, this just gave me an idea!
Block scope redefinitions of classes!

withImaginaryHungryNilConstruct do
while(line = gets.chomp )
# do stuff with line
end
end # here NilClasses's definition reverts back to normal

You could do this in Ruby now, the only problem being is it would have
dynamic and not lexical "scope" if I may obscenely misuse a term. This
could be quite useful, I imagine, especially if it was generic (eg.
have a way of saying use these modifications for class X for the
duration of this block).

You might want to read this:

http://nbtsc.org/~aredridel/2005/02/14-aspects.log
 
D

David A. Black

Hi --

Ooo, this just gave me an idea!

Block scope redefinitions of classes!

Welcome to the club :) See my "Ruby Behaviors" package. as well as
Class-in-State and Import Module (all available on RAA).

It sounds like there might be something that provides this kind of
functionality in Ruby 2.0, in the form of selector namespaces.


David
 
L

Logan Capaldo

Hi --



Welcome to the club :) See my "Ruby Behaviors" package. as well as
Class-in-State and Import Module (all available on RAA).

It sounds like there might be something that provides this kind of
functionality in Ruby 2.0, in the form of selector namespaces.

David

Darn, now I don't feel nearly as smart. Oh well, the upside is I don't
have to write the code myself ;)
 
I

Ian Macdonald

This is in contrast to the fact that certain bang methods sometimes
return nil -- that behavior I've also seen justified, and can easily
imagine use cases, but I still have never liked it. It's one of my
most common bugs, personally. And not once have I ever *wanted* the
"return nil" behavior.

I've occasionally found this to be useful, in constructs such as:

unless url.sub!( %r(^file://), '' )
raise "Invalid file URL: #{url}"
end

Here, the combination of performing the substitution and checking
whether it actually happened is quite useful.

Ian
--
Ian Macdonald | Documentation is like sex: when it is good,
System Administrator | it is very, very good; and when it is bad,
(e-mail address removed) | it is better than nothing. -- Dick
http://www.caliban.org | Brandon
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,169
Messages
2,570,918
Members
47,458
Latest member
Chris#

Latest Threads

Top