ruby-dev summary 27393-27541

C

Christophe Grandsire

Selon Kero :
holds as well for

jcode $chop
jcode :chop
chop :jcode

and probably some other ideas in this thread.

Exactly. I wanted to reply that but you beat me to it :) . If matz and
others find it good enough to implement jcode$chop, alternatives should
be as good enough :) .
I recall someone asking whther namespaces would be 'different' from
methods, i.e. if there is also a *method* jcode in the example above,
the space is really wreaking havoc.

That was me again :) . I had also already thought of that problem, which
is why I said that there shouldn't be any space allowed between the
method and the namespace using such a syntax. Namespaces, when used
directly with a method, should indeed be considered *part* of the name
of that method. And since we don't have methods which allow a space in
their name (short maybe of using exotic method definitions with
define_method, and even then I don't know if it's possible), I don't
think we should allow it if we add namespaces to them.

I agree on the other hand that the "using" suffix idea solves the
problem neatly, except that it breaks havoc with method chaining.

Anyway, it's not as if Ruby's philosophy is "there's only one way to do
it" ;) . I don't see why we couldn't have a $, :, @ or whatever syntax
*and* a "using" suffix (or prefix?), although with the "using", to
prevent unsolvable issues about how two "using"s might work with each
other in case of method chaining, we would restrict to 1 "using". If you
need to chain methods from different namespaces, use the $, @, : or
whatever syntax.

On the subject of "using", what should happen if we call a method in the
scope of a "using" (whether it is "using namespace", "using namespace
{...}, or "obj.method using namespace") that is *not* redefined in that
namespace. Should we get an error, a warning, or should the original
method from that object simply be called without any warning. I'm
personally leaning toward a warning, and let the original method of the
object be used. Maybe the warning should be there only in verbose
output... I'm curious what others think about that.
--
Christophe Grandsire.

http://rainbow.conlang.free.fr

You need a straight mind to invent a twisted conlang.
 
M

Michel Martens

class String
scope :japanese do
def chop
...
end
end
end

"Tsumego".scope:)japanese).chop

scope :japanese do
"Tsumego".chop
end
 
G

gabriele renzi

Christian Neukirchen ha scritto:
Now, what is the advantage over doing

p "\244\242\244\244".jchop

? I thought the purpose of namespaces was to allow for the methods to
be redefined transparently, without mentioning the namespace all
over...

this is exactly the same thing that I was thinking.
I think we need some more use cases before we keep on talking about this
bicycle shed :)
 
T

Trans

this is exactly the same thing that I was thinking.
I think we need some more use cases before we keep on talking about this
bicycle shed :)

He he. Seems like no one read my first post to this thread. I don;t
think they are doing anything different from this except providing a
way to wrap then into a "using case". Hence this is nothing more then

define_method( 'jcode$chop' ) do
...
end

And then #using prefixes subsequent method calls.

While it is nice in it simplicity, I do not beleive it constitues a
complete namespace selector solution.

T.
 
G

gabriele renzi

Trans ha scritto:
He he. Seems like no one read my first post to this thread.

Actually, I did not, it did not appear in my newsreader :/
I don;t
think they are doing anything different from this except providing a
way to wrap then into a "using case". Hence this is nothing more then

define_method( 'jcode$chop' ) do
...
end

And then #using prefixes subsequent method calls.

While it is nice in it simplicity, I do not beleive it constitues a
complete namespace selector solution.

I think I agree
 

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
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top