What a language!

B

benny

just another ruby gotcha:

to prevent namespace pollution from abitrary loaded files with code in it, I
had the idea to evaluate the code in anonymous modules, that are saved in a
hash (key is the filename/path).

worked so far, no problem.

then I tried to include the anonymous modules to have comfortable access to
the classes and methods of the corresponding files and guess what... it
worked!

include anonymous modules! whow! I am really impressed!
this language let me try things I would not think about in other languages.

thank you matz and the other developers for this great language!

benny





--
---------------------------------------------------------------------------------------------------
Don't crash when a filter changes the subject of a message which results
in the attempt to remove it from the tree of subject threading messages
failing and the detached child looking for a new parent finding the old
parent as the new parent, which in turn results in the child being deleted
with the old (and new) parent, which is not a good idea, since it is
still referenced.

(Till Adams commit on kdepim/kmail/kmheaders.cpp in HEAD, 6. Jan. 2005)
 
J

Joao Pedrosa

Hi,

just another ruby gotcha:

to prevent namespace pollution from abitrary loaded files with code in it, I
had the idea to evaluate the code in anonymous modules, that are saved in a
hash (key is the filename/path).

worked so far, no problem.

then I tried to include the anonymous modules to have comfortable access to
the classes and methods of the corresponding files and guess what... it
worked!

include anonymous modules! whow! I am really impressed!
this language let me try things I would not think about in other languages.

It's great to see that the creativity isn't capped with Ruby. It is
always surprising to find out what people like you can come up with. I
haven't freed up my mind like that yet. :)
thank you matz and the other developers for this great language!

Indeed. Big thanks. He saw a lot of this 10 years ago, can you imagine
how lucky we are? :) hehe

Matz 1.0 was great already. :)

Cheers,
Joao
 
N

Nikolai Weibull

* benny (Feb 10, 2005 01:30):
Don't crash when a filter changes the subject of a message which results
in the attempt to remove it from the tree of subject threading messages
failing and the detached child looking for a new parent finding the old
parent as the new parent, which in turn results in the child being deleted
with the old (and new) parent, which is not a good idea, since it is
still referenced.
(Till Adams commit on kdepim/kmail/kmheaders.cpp in HEAD, 6. Jan. 2005)

Totally off topic, but what a comment!
nikolai
 
E

Eric Hodel

--Apple-Mail-71-840595374
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII; format=flowed

just another ruby gotcha:

to prevent namespace pollution from abitrary loaded files with code in
it, I
had the idea to evaluate the code in anonymous modules, that are saved
in a
hash (key is the filename/path).

worked so far, no problem.

then I tried to include the anonymous modules to have comfortable
access to
the classes and methods of the corresponding files and guess what... it
worked!

include anonymous modules! whow! I am really impressed!
this language let me try things I would not think about in other
languages.

thank you matz and the other developers for this great language!

If you don't need to do anything with the anonymous namespace:

$ ri Kernel#load
------------------------------------------------------------ Kernel#load
load(filename, wrap=false) => true
------------------------------------------------------------------------
Loads and executes the Ruby program in the file _filename_. If the
filename does not resolve to an absolute path, the file is searched
for in the library directories listed in +$:+. If the optional
_wrap_ parameter is +true+, the loaded script will be executed
under an anonymous module, protecting the calling program's global
namespace. In no circumstance will any local variables in the
loaded file be propagated to the loading environment.

$ cat x.rb
Foo = 5

puts "x here, is there a Foo? #{defined? Foo}"

$ cat y.rb
load 'x.rb', true

puts "y here, is there a Foo? #{defined? Foo}"

$ ruby y.rb
x here, is there a Foo? constant
y here, is there a Foo?

--
Eric Hodel - (e-mail address removed) - http://segment7.net
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

--Apple-Mail-71-840595374
content-type: application/pgp-signature; x-mac-type=70674453;
name=PGP.sig
content-description: This is a digitally signed message part
content-disposition: inline; filename=PGP.sig
content-transfer-encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)

iD8DBQFCCrCOMypVHHlsnwQRAhIaAJ9GBlt96iG278BwlrBobWDlpOZ1DACguUdO
HgELUTfVUEEf2n3D0R8JPHM=
=R3Ij
-----END PGP SIGNATURE-----

--Apple-Mail-71-840595374--
 
N

Navindra Umanee

Douglas Livingstone said:
Bets that there are nocomments like that in any production Ruby app?

Instead we get huge mysterious memory leaks. :)

Cheers,
Navin.
 
J

Joao Pedrosa

Hi,

Instead we get huge mysterious memory leaks. :)

This is a problem with all the languages, even with the garbage
collected ones. :) "More creativity + More done" is the real cause of
the memory leaks in languages like Ruby. :) But Java too has such
problems, mind you. It's good to bring up this because reality is
usually a little bit harder in every language.

Regards,
Joao
 
B

benny

Eric said:
If you don't need to do anything with the anonymous namespace:

$ ri Kernel#load

yes I know, but I needed to reuse the modules later

benny

--
---------------------------------------------------------------------------------------------------
Don't crash when a filter changes the subject of a message which results
in the attempt to remove it from the tree of subject threading messages
failing and the detached child looking for a new parent finding the old
parent as the new parent, which in turn results in the child being deleted
with the old (and new) parent, which is not a good idea, since it is
still referenced.

(Till Adams commit on kdepim/kmail/kmheaders.cpp in HEAD, 6. Jan. 2005)
 
B

benny

Nikolai said:
* benny (Feb 10, 2005 01:30):


Totally off topic, but what a comment!
nikolai
I saw this commit message on the kde cvs-digest and wanted to use it as
signature. so I asked Mr. Adams if I may. He was amused and gave me the ok.

its a bit long for the usenet so I will replace it as soon as I made my
first ruby-onliner poem

:)

benny
 
D

David A. Black

Hi --

I saw this commit message on the kde cvs-digest and wanted to use it as
signature. so I asked Mr. Adams if I may. He was amused and gave me the ok.

its a bit long for the usenet so I will replace it as soon as I made my
first ruby-onliner poem

Here's one you can use:

puts "What a language!"

(I know it isn't illegible, or borrowed from Perl, or anything like
that, but I think it's just fine :)


David
 
D

Dave Burt

Nikolai Weibull said:
* benny (Feb 10, 2005 01:30):

It needs parentheses and syntax highlighting (colour verb-like bits red)...

Don't crash when ((a filter changes (the subject of a message)) which
results
in (the attempt to remove it from (the tree of subject threading messages)
failing) and ((the detached child looking for a new parent) finding the old
parent as the new parent), which in turn results in (the child being deleted
with (the old \(and new\) parent), (which is not a good idea, since it is
still referenced))).

Hope this helps :))

Dave
 
A

Alan Garrison

David said:
Here's one you can use:

puts "What a language!"

(I know it isn't illegible, or borrowed from Perl, or anything like
that, but I think it's just fine :)
And name it yakov.rb (when I saw the subject text I first
thought of Yakov Smirnoff's "What a country!" bit).

In Soviet Russia Ruby codes you!
 

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,167
Messages
2,570,911
Members
47,453
Latest member
MadelinePh

Latest Threads

Top