Little Things

Hi –

On Sun, 31 Dec 2006, Eric H. wrote:

know of. #send and #funcall match what the written methods look like
perfectly.

But #foo/#foo! behaviors don’t have to match each other, except at the
very abstract level of one being “dangerous”. I’ve always thought
that including private methods vs. not including them was a good
candidate for dangerous, but Matz didn’t agree in this case so I don’t
think it will happen.

#send and #funcall sort of match what the written methods might look
like (sometimes; not in the case of setter methods, and not for public
methods where you used a receiver) if you called them. It just seems
to me to be a pretty tenuous connection.

David

On Sun, Dec 31, 2006 at 09:20:34PM +0900, [email protected] wrote:

No please. That doesn’t match the behavior of any other #foo, #foo! that
I know of. #send and #funcall match what the written methods look like
perfectly.

But #foo/#foo! behaviors don’t have to match each other, except at the
very abstract level of one being “dangerous”. I’ve always thought
that including private methods vs. not including them was a good
candidate for dangerous, but Matz didn’t agree in this case so I don’t
think it will happen.

Actually, in 1.9 you have send, funcall, __send and __send!.
These last ones might disappear at any time, but my hunch is that
there’s a
chance they’ll stay. But it’s just the gut feeling of somebody who’s
been
tracking Ruby 1.9 for a while and has seen features come by and go.

Reading the sources/changelogs periodically can be tiresome, so I’ve
been
maintaining this change summary for some time:

http://eigenclass.org/hiki.rb?Changes+in+Ruby+1.9#l22

Hi –

On Sun, 31 Dec 2006, Mauricio F. wrote:

Actually, in 1.9 you have send, funcall, __send and __send!.
These last ones might disappear at any time, but my hunch is that there’s a
chance they’ll stay. But it’s just the gut feeling of somebody who’s been
tracking Ruby 1.9 for a while and has seen features come by and go.

Thanks for the update. I really must try to stay more on the edge of
1.9 :slight_smile:

David

On 12/31/06, Suraj K. [email protected] wrote:

I think “funcall” is just an artifact of the rb_funcall()
function—which invokes a method on an explicit receiver—from
Ruby’s C interface.

Ultimately, it’s a lispism.

http://www.n-a-n-o.com/lisp/cmucl-tutorials/LISP-tutorial-20.html

martin

What about:

obj.send(:foo) # will call only public
obj.send!(:foo) # will bypass private/protected, like the current send.

I don’t normally weigh in on these discussions, but since it’s come up
again I’m strongly +1 for this.

reads better then funcall to me, at least.

I know very little lisp, and though the private method == function link
makes sense, it’s pretty esoteric.

I don’t know what I’d expect a funcall method to do … dial 0800 FUN
NOW ?

happy new year
alex

Hi,

In message “Re: Little Things”
on Sun, 31 Dec 2006 21:12:07 +0900, [email protected] writes:

|Me too – that was what I suggested long ago :slight_smile: Matz didn’t feel it
|corresponded to his concept of a ! (dangerous) method.

I often change my mind, especially for 1.9. See Mauricio’s post in
[ruby-talk:231912].

						matz.

Hi,

I’d like to see them as separated RCRs, even though the new RCR site
have not seen its successful start-up yet.

In message “Re: Little Things”
on Sun, 31 Dec 2006 02:27:14 +0900, “Trans” [email protected]
writes:

|* Binding.of_caller. Yes, it’s easy to abuse, and should be avoided at
|nearly all costs. But there are few pennies worth when nothing else
|will do. Some very cool metatricks are made possible by being able to
|access the caller’s binding --the breakpoint lib being the most well
|known.

The biggest reason we don’t have caller binding API is the difficulty
of the implementation under the current interpreter. ko1 once said it
is possible for YARV, so all we need is to design good API. I don’t
think of_caller is the best name for it.

By the way, YARV was committed in the Subversion trunk yesterday.

|* object_class instead of class. I get sick
|just looking at self.class.foo. And it prevents use of
|“class” for other variables/methods. (Hence the all too frequent use of
|“klass”). object_class on the other hand is nicely
|analogous to object_id.

Could you describe what this change give you? Removing class method
does not allow local variables to be named ‘class’. Besides that I
don’t like the name “object_class”, which is too vague for me. class
of an object? a class object? an object which is a class? whatever.
Maybe because I see many combination of “something id” but not
“something class”, besides “business class” etc.

|* Allow a comma between the two alias arguments --getting
|an error on that is really annoying. Actually why is alias
|a keyword? Why have both #alias_method and
|alias? I have always been told that keywords were to be
|avoided.

Are you proposing comma between alias arguments, or removal of the
alias keyword?

|* String#resc as an inversion of
|Regexp.escape(string) and String#to_re as an
|inversion of Regexp.new(string).

Why?

|* I’m dying here from remove_method hacks without
|#instance_exec. This has to rank in the top three “little
|things” that have been talked about forever, and it isn’t that hard to
|implement. So what’s holding it up?

We have it in 1.9.

|* A block can’t take a block, nor default arguments. What kind of
|define_method is this? I realize this a trickier issue.
|But at some point the trick has to be performed.

We have it in 1.9; well, at least partially.

|* Close the closures. Writing DSLs is great, but have you noticed they
|all share the same closure? Have a way to reset the closure with some
|sort of special block notation would shore-up this danger hole. Maybe:
|
|


| a = 1
| dosomething do! |x|
| p a #=> error
| end
|

I am not sure what you meant here. Could you elaborate (maybe in a
separate post)? Does any other language address this issue?

|* Another hassle when metaprogramming. #send should work
|for public methods only! There’s a big issue with backward
|compatibility here. I have the solution: #object_send.
|It’s a better name anyway b/c it stays out of the way (eg. my Email
|module would like to have a #send method, you dig?). And #send itself
|could be deprecated slowly. BTW #funcall for the alternate
|private-accessing send is a terrible name, try
|#instance_send. (And yes, I’m begging here!)

We have send, funcall, __send, __send! in 1.9. Do we need more?

|* This one’s more of my own pet-peeve but nontheless, who wouldn’t want
|a nice word alias for Class#===. In most cases I prefer to read what
|I’m doing rather then recall the interpretation of a symbol. There are
|of course some symbols that are rather obvious, either by indication of
|their form (eg. <<) or by their widespread use (eg. =), but Class#===
|is not one of them. I would much prefer to see:
|
|


| MyClass.instance?(myobject)
|

|
|But I’m not picky about what word to use as long as it’s readable.

In short, you are asking for the alias for Module#===, right?
I don’t see any good reason for it, where we can call

myobject.instance_of?(MyClass)

but the good name for it would help accepting the proposal.

|* Oh, and lets not forget the forever arguable method name for (class
|<< self; self; end). But please give us something concise.

Yes, the name is the biggest obstacle now.

|No doubt there other little things left unmentioned, and obviously some
|are more important than others. But in any case, it’s clearly striking
|that after hearing for so long about many such well-accepted “little
|things”, that Ruby has yet to take them in. I have a silly theory about
|this actually --as odd as it may seem. The 1.9 version is the last on
|the chain before 2.0 b/c matz is against using double-digit minor
|numbers, eg 1.10. So we’re is stuck with 1.9 as his test bed for 2.0.
|Since 1.8 can only increment by teeny, these “little things”, being not
|little enough, can’t make it in. Hence Ruby is being held back by a
|version number policy!!! I think Matz just needs to get on with it (hey
|look forward to 3.0!) or just lossen the version policy constraints.

Digits that we have many (hey, we could have 9 more major releases!)
are not the reason. Expected screams from all over the world suspends
incompatibility and behavior changing for 1.8.

						matz.

Just one quick comment:

“[…] what could potentially kill the language.
We can have the best language on the Planet, but if the language
features are only accessible to those that are willing to go code-diving
for the answers, then the target audience is going to be slim.”

I disagree to the potential of this.
I myself am sometimes annoyed at the lack of any
documentation, this sometimes involve old code - new code
almost always is nicely documented :slight_smile:

However, only a lack of docu wont stop me from using
ruby. Most naturally because I do not HAVE to use 100%
of the language, and books like the pickaxe really
did help a LOT - IF any docu has to be added, then
i’d look at these things first :wink:

  • More focus on the C part of Ruby. Its a little bit
    difficult to find enough good quality documents about
    extending Ruby in C
  • Allow only code into stdlib etc… that has a minimum
    docu
  • Replacement for ri/rdoc or updating, so many people
    rely on it for documenting their code, but the
    html frame alone isnt always that appealing, and
    ri can sometimes be slow, silly or… well
  • Ruby website should offer online docu similar to how
    php does. Php as a language is a curse, but the
    online docu is rather good. I think ruby should
    take up the idea of providing good online docu.

Anyway… just some of my long 2 cc, dont mean
to interrupt! :smiley:

Hi –

On Mon, 1 Jan 2007, Yukihiro M. wrote:

Hi,

In message “Re: Little Things”
on Sun, 31 Dec 2006 21:12:07 +0900, [email protected] writes:

|Me too – that was what I suggested long ago :slight_smile: Matz didn’t feel it
|corresponded to his concept of a ! (dangerous) method.

I often change my mind, especially for 1.9. See Mauricio’s post in
[ruby-talk:231912].

I saw – it was a good reminder that I need to catch up on the latest
1.9’s :slight_smile:

David

Yukihiro M. wrote:

|* Oh, and lets not forget the forever arguable method name for (class
|<< self; self; end). But please give us something concise.

Yes, the name is the biggest obstacle now.
I take it you don’t like meta_class, the most often proposed name for
it. How about virtual_class, or singleton_class, or both?

irb(main):001:0> a=5; def a.foo; end
TypeError: can’t define singleton method “foo” for Fixnum
from (irb):1
irb(main):002:0> a=""; class Foo < (class << a; self end); end
TypeError: can’t make subclass of virtual class
from (irb):2

:slight_smile:

Devin
(Sorry, I don’t know what’s already been proposed. Shame on me for not
researching it…)

Hi –

On Mon, 1 Jan 2007, Devin M. wrote:

   from (irb):1

irb(main):002:0> a=""; class Foo < (class << a; self end); end
TypeError: can’t make subclass of virtual class
from (irb):2

:slight_smile:

Devin
(Sorry, I don’t know what’s already been proposed. Shame on me for not
researching it…)

Just about every word in the English language, and a couple in German,
has been proposed :slight_smile:

David

[email protected] wrote:

about virtual_class, or singleton_class, or both?
Devin
(Sorry, I don’t know what’s already been proposed. Shame on me for not
researching it…)

Just about every word in the English language, and a couple in German,
has been proposed :slight_smile:

And one Latin :wink:

T.

On Dec 31, 2006, at 12:34 PM, Yukihiro M. wrote:

We have send, funcall, __send, __send! in 1.9. Do we need more?

If __send! is OK, can we have the alias send! as well? I thought we
wanted the get away from method names like this.

James Edward G. II

Hey matz,

thanks for taking the time to respond to these.

I’d like to see them as separated RCRs, even though the new RCR site
have not seen its successful start-up yet.

If the RCR process gets fixed I would be happy to do some of them.
Right now only two people have submitted RCRs (last I checked) and the
communication on those RCRs is either broken or simply not being used
–I made attempts at emailing on the second --and I sumbitted the first
:wink:

The biggest reason we don’t have caller binding API is the difficulty
of the implementation under the current interpreter. ko1 once said it
is possible for YARV, so all we need is to design good API. I don’t
think of_caller is the best name for it.

Really? By simply passing a block I can pass the binding of the caller.
I suppose passing a hidden block is too heavy though?

By the way, YARV was committed in the Subversion trunk yesterday.

w00t!

Could you describe what this change give you? Removing class method
does not allow local variables to be named ‘class’. Besides that I
don’t like the name “object_class”, which is too vague for me. class
of an object? a class object? an object which is a class? whatever.
Maybe because I see many combination of “something id” but not
“something class”, besides “business class” etc.

The main thing is that it creates an exception b/c we are forced to use
a reciever, eg. self.class, so it can’t be called as a “function” nor
made private. No other method is like that. Also I don’t see why we
can’t use it as a local var. Isn’t the conflict with class<<obj
notation? Probably the parser should see /class\s+<</ as a whole unit,
which I think would allow for the var. But if you ask me the whole
“class << obj” notaton is yuk anyway. It visually clashes with Array#<<
and I’d much prefer someting like ‘obj.meta_eval’ -or-
‘obj.singleton_eval’.

|* Allow a comma between the two alias arguments --getting
|an error on that is really annoying. Actually why is alias
|a keyword? Why have both #alias_method and
|alias? I have always been told that keywords were to be
|avoided.

Are you proposing comma between alias arguments, or removal of the
alias keyword?

Well, both. First and foremost however is the option of a comma. What
good reson is there for getting getting a sytax error here?

As for makeing alias a real method, that seems like a good idea. it
would allow us to use ‘alias’ as a var too.

If it possible to get rid of an exception and have things still work
fine, then it’s a good thing, isn’t it?

|* String#resc as an inversion of
|Regexp.escape(string) and String#to_re as an
|inversion of Regexp.new(string).

Why?

It’s much more concise. Take a simple example:

re = /^#{user_input}/

We need to escape it:

re = /^#{Regexp.escape(user_input)}/

vs.

re = /^#{user_input.resc}/

The to_re, just goes hand in hand with resc, since they both regular
expresions --maybe resc should be to_resc, but tersness is especially
useful with it so I suggest resc instead.

|* I’m dying here from remove_method hacks without
|#instance_exec. This has to rank in the top three “little
|things” that have been talked about forever, and it isn’t that hard to
|implement. So what’s holding it up?

We have it in 1.9.

Yea! But why not a 1.8 serious. It’s an additon it won’t break
anything. Correct me if I’m wrong, but I fear we won’t see anything
from 1.9 in production for almost 2 years.

I am not sure what you meant here. Could you elaborate (maybe in a
separate post)? Does any other language address this issue?

Okay. I will post separately.

We have send, funcall, __send, __send! in 1.9. Do we need more?

So we have the functionality. But can you tell me with a straight face
those are great method names?

Peronally, I really think you should get rid of shadow methods
wherever you can. All it indicates is that the original method’s name
is too common, so is likely to be overridden. And that’s the reason I
suggest #object_send. All methods starting with object
or instance

are special. They are meta-programming methods and as such need to
stand aside in some fashion to avoid being overridden easily. This
consistancy is the beauty of it.

In short, you are asking for the alias for Module#===, right?
I don’t see any good reason for it, where we can call

myobject.instance_of?(MyClass)

but the good name for it would help accepting the proposal.

Yes. that’s right. But I learned that it is better to ask the class if
you want to know the “truth”. Sometimes the object might need to lie
–eg. as a proxy. I guess the most obvious name is:

MyClass.class_of?(myobject)

|* Oh, and lets not forget the forever arguable method name for (class
|<< self; self; end). But please give us something concise.

Yes, the name is the biggest obstacle now.

#supercalifragilisticexpialidocius

Almost anything is better than nothing at this point… okay maybe not
THAT, but you get my point.

|look forward to 3.0!) or just lossen the version policy constraints.

Digits that we have many (hey, we could have 9 more major releases!)

Good! :slight_smile:

are not the reason. Expected screams from all over the world suspends
incompatibility and behavior changing for 1.8.

Yet most of these have no backward compatability issues --I guess
that’s really my main point with “Little things”

Thanks and happy new year,
T.

Devin M. wrote:

Trans wrote:

The main thing is that it creates an exception b/c we are forced to use
a reciever, eg. self.class, so it can’t be called as a “function” nor
made private. No other method is like that.
Actually, two classes of method names come to mind:

  • Those that share a name with a keyword (class, when, def, etc.)

That’s a good point. Although ‘when’, ‘def’ and others aren’t also
built-in methods. And in a private context at least, no one is going to
readily use them as such.

  • Setter methods (/=$/, that is)

There’s an exception for the latter – when private, they can be called
with self as an explicit receiver.

True. An expection I never liked, but it’s neccessary, and at least
it’s a very simple pattern.

Neither defending the behavior nor arguing for a change… just playing
Mr. Fact Checker (or Mr. Obvious, depending on your POV).

facts == good

Thanks,
T.

Trans wrote:

The main thing is that it creates an exception b/c we are forced to use
a reciever, eg. self.class, so it can’t be called as a “function” nor
made private. No other method is like that.
Actually, two classes of method names come to mind:

  • Those that share a name with a keyword (class, when, def, etc.)
  • Setter methods (/=$/, that is)

There’s an exception for the latter – when private, they can be called
with self as an explicit receiver.

Neither defending the behavior nor arguing for a change… just playing
Mr. Fact Checker (or Mr. Obvious, depending on your POV).

Devin

Devin M. wrote:

(Sorry, I don’t know what’s already been proposed. Shame on me for not
researching it…)

For what it’s worth, I started a wiki page a while ago (and others have
contributed) with the crazy huge list of suggested names, with some
discussion on some of them:

http://wiki.rubygarden.org/Ruby/page/show/RenamingSingletonClass

Hi –

Happy New Year!

On Mon, 1 Jan 2007, Yukihiro M. wrote:

In my mindset, two candidates have survived. singleton_class (or
singletonclass), which can easily be confused with a class in the
singleton design pattern. And eigenclass, which is unfamiliar for
most people.

I don’t think the “singleton” confusion is a big problem. I’ve heard
many people say that it might be confusing, but very few people
actually be confused by it. And if they are, it’s worth the three
seconds it takes them to learn the difference :slight_smile:

Also, unless we’re supposed to start using the term “eigenmethod” for
singleton methods, singleton_class is a better match in that sense.

David

|I take it you don’t like meta_class, the most often proposed name for
|it. How about virtual_class, or singleton_class, or both?

It’s not really a meta class since it’s not only for classes,
nor virtual_class since it’s not virtual anymore.

I wonder: is it a mistake to think of it as a class at all? Sure, it
had a ‘class’ somewhere in its background, but is potentially moved
on a lot since then. In a way, it’s move analogous to a meta-binding,
as it’s the execution environment of an object. So, just to get the
creative juices flowing, and in the spirit of brainstorming, how about

obj.personality

obj.capability

obj.implementation

Cheers

Dave

Hi,

In message “Re: Little Things”
on Mon, 1 Jan 2007 23:38:57 +0900, Dave T. [email protected]
writes:

|I wonder: is it a mistake to think of it as a class at all? Sure, it
|had a ‘class’ somewhere in its background, but is potentially moved
|on a lot since then. In a way, it’s move analogous to a meta-binding,
|as it’s the execution environment of an object. So, just to get the
|creative juices flowing, and in the spirit of brainstorming, how about
|
|obj.personality
|obj.capability
|obj.implementation

The “implemantation” is not what we’re talking about.

The “personality” and “capability” of an object are characteristics of
the object, combined from attributes of its class and superclasses.
“That something” here is not these characteristics themselves, but a
handle to tweak them by per object basis. Calling a handle by
characteristics may cause confusion.

						matz.