String starts? and ends? methods

Sorry for entering this thread now to give my two cents. I'm sorry
because I'm a Ruby newbie AND a non-native english speaker, but I
thought I should say this.

I don't think the person is really the question here. I think it's the
imperative form of the verb.
In that case, I have always interpreted that (both in english and in
my native language) as you telling the string to squeeze itself.
File.open, for example, reads like "Hey, File class, open this for me,
please". I'm imperative, but polite :).

I think that's why most methods which do not ask for something are
written like that. I'd also prefer the "starts_with?" name, but if
"start_with?" is more consistent, I say stay with that.

Cheers,
Alvim.

···

On 9/27/06, Pete Yandell <pete@notahat.com> wrote:

For non-predicate methods, the second person makes sense. Take
String.squeeze for example...that's really about you (the second
person) squeezing the string.

I think you're absolutely right Marcelo, and you've once again proved that non-native English speakers tend to know way more about grammar than native English speakers like me. :slight_smile:

Pete Yandell

···

On 28/09/2006, at 12:36 PM, Marcelo Alvim wrote:

On 9/27/06, Pete Yandell <pete@notahat.com> wrote:

For non-predicate methods, the second person makes sense. Take
String.squeeze for example...that's really about you (the second
person) squeezing the string.

Sorry for entering this thread now to give my two cents. I'm sorry
because I'm a Ruby newbie AND a non-native english speaker, but I
thought I should say this.

I don't think the person is really the question here. I think it's the
imperative form of the verb.
In that case, I have always interpreted that (both in english and in
my native language) as you telling the string to squeeze itself.
File.open, for example, reads like "Hey, File class, open this for me,
please". I'm imperative, but polite :).

Marcelo Alvim wrote:

For non-predicate methods, the second person makes sense. Take
String.squeeze for example...that's really about you (the second
person) squeezing the string.

Sorry for entering this thread now to give my two cents. I'm sorry
because I'm a Ruby newbie AND a non-native english speaker, but I
thought I should say this.

I don't think the person is really the question here. I think it's the
imperative form of the verb.
In that case, I have always interpreted that (both in english and in
my native language) as you telling the string to squeeze itself.
File.open, for example, reads like "Hey, File class, open this for me,
please". I'm imperative, but polite :).

Interesting. Some methods are imperative in form. But the ones
that are interrogative take the form they do (IMO) because it's
the infinitive form of the verb. (Of course, the imperative
usually uses the infinitive...)

I think that's why most methods which do not ask for something are
written like that. I'd also prefer the "starts_with?" name, but if
"start_with?" is more consistent, I say stay with that.

We agree on that. Besides, after 13 years, this convention is not
likely to change.

Hal

···

On 9/27/06, Pete Yandell <pete@notahat.com> wrote:

There seem to be two kinds of predicates -- those which ask about what
an object is like, and those which ask about what it is; e.g:

obj.respond_to? :m # does obj respond to :m?
obj.include? item # does obj include item?
obj.all? { cond } # do all members of obj meet cond?

obj.is_a? Class # is obj a Class?
obj.instance_of? Class # is obj an instance of Class?
obj.nil? # is obj nil?

#start_with? seems to fit into the first category, and to be consistant
with the grammar of that category:

obj.start_with? 'string' # does obj start with 'string'?

Regards,
Jordan

Well, according to

most modern grammarians don't consider the imperative and present
subjunctive to be uses of the bare infinitive.

I think that the older view that they are the same might actually an
example of the trap of thinking that English grammar is the same as
or very similar to Latin grammar.

A good example of this is the old-fashioned prohibition against
splitting an infinitive. "To go boldly where no one has gone before,"
instead of "To boldly go where no one has gone before." This came
from the fact that in Latin, and some of it's descendants, the
infinitive was/a single word, so splitting an infinitive is
impossible, whereas in English the use of the full infinitive (to x)
is much more common than the bare infinitive, and splitting an
infinitive seems to be both commonly used and often sounds and flows
better. The prohibition, like not ending a sentence with a
preposition, is "something, up with which I will not put."

As an analogy to what is commonly said here:

    Ruby is not Java
    Python is not Ruby
    Ruby is not C++
    English is not Latin
    Le francais, n'est pas l'anglais.

Not that this is a big thing with me, I just find it interesting.

···

On 9/28/06, Hal Fulton <hal9000@hypermetrics.com> wrote:

Marcelo Alvim wrote:

> I don't think the person is really the question here. I think it's the
> imperative form of the verb.
> In that case, I have always interpreted that (both in english and in
> my native language) as you telling the string to squeeze itself.
> File.open, for example, reads like "Hey, File class, open this for me,
> please". I'm imperative, but polite :).

Interesting. Some methods are imperative in form. But the ones
that are interrogative take the form they do (IMO) because it's
the infinitive form of the verb. (Of course, the imperative
usually uses the infinitive...)

--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

>> For non-predicate methods, the second person makes sense. Take
>> String.squeeze for example...that's really about you (the second
>> person) squeezing the string.
>
> Sorry for entering this thread now to give my two cents. I'm sorry
> because I'm a Ruby newbie AND a non-native english speaker, but I
> thought I should say this.
>
> I don't think the person is really the question here. I think it's the
> imperative form of the verb.
> In that case, I have always interpreted that (both in english and in
> my native language) as you telling the string to squeeze itself.
> File.open, for example, reads like "Hey, File class, open this for me,
> please". I'm imperative, but polite :).

I think you're absolutely right Marcelo, and you've once again proved
that non-native English speakers tend to know way more about grammar
than native English speakers like me. :slight_smile:

by force of nature, we have to study it to learn,
OTOH method names ending in "?" are hardly imparative forms [ I guess that
was what Pete was refering to]

but why not making things easier and being more tolerant :slight_smile:

in the beginning I had to correct #responds_to? with #respond_to? what
seemed a zillion times (I should have aliased it in Object anyway, but when
I knew how to do that I did not need it anymore :wink:
.
Aliases are commonly used in Ruby Array#collect, Array#map etc

why not having them for flected forms
String#starts_with? <=> String#start_with?
personally I like String#prefix? and String#suffix? too, shorter and very
precise.

Object#responds_to? <=> ...

I guess it will make life easier for Newbies and let everybody use it's
personal feeling for what sounds better.

Cheers
Rober

Pete Yandell

···

On 9/28/06, Pete Yandell <pete@notahat.com> wrote:

On 28/09/2006, at 12:36 PM, Marcelo Alvim wrote:
> On 9/27/06, Pete Yandell <pete@notahat.com> wrote:

--
Deux choses sont infinies : l'univers et la bêtise humaine ; en ce qui
concerne l'univers, je n'en ai pas acquis la certitude absolue.

- Albert Einstein

Not that it's going to change, and it's all water long under the bridge, but....

Those predicates are usually part of a larger expression.

We wouldn't say

Give me my nine-iron, if does my bag have my nine-iron.

In situ which of these sounds better to the English speaker?

do_something if a.start_with?('foo')
do_something if a.respond_to?(:fred)
do_something if a.include?(:joe)

or

do_something if a.starts_with?('foo')
do_something if a.responds_to?(:fred)
do_something if a.includes?(:joe)

Try it with other statements and modifiers like unless, while, until etc.

···

On 9/28/06, MonkeeSage <MonkeeSage@gmail.com> wrote:

There seem to be two kinds of predicates -- those which ask about what
an object is like, and those which ask about what it is; e.g:

obj.respond_to? :m # does obj respond to :m?
obj.include? item # does obj include item?
obj.all? { cond } # do all members of obj meet cond?

obj.is_a? Class # is obj a Class?
obj.instance_of? Class # is obj an instance of Class?
obj.nil? # is obj nil?

#start_with? seems to fit into the first category, and to be consistant
with the grammar of that category:

obj.start_with? 'string' # does obj start with 'string'?

--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

That was my first thought.

On the other hand it could lead to ethnic enclaves in the ruby
community based on different dialects or accents.

CockneyRuby, SouthernDrawlRuby, LanguedocRuby, SchweizerdeutschRuby? <G>

I used to tell people I met in Zurich that I felt like I was Swiss
since my mother's parents were German, my father's parents were
Italian, et je parle un peu de francais! <G>

···

On 9/28/06, Robert Dober <robert.dober@gmail.com> wrote:

Aliases are commonly used in Ruby Array#collect, Array#map etc

why not having them for flected forms
String#starts_with? <=> String#start_with?
personally I like String#prefix? and String#suffix? too, shorter and very
precise.

Object#responds_to? <=> ...

I guess it will make life easier for Newbies and let everybody use it's
personal feeling for what sounds better.

--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

...if it's true that my bag does have my nine-iron

"has", "starts" and so on eliminate the 'be' verb in favor of
complicating (by conjugating) the original verb. Having lived as an
English speaker and studied other languages that both conjugate and do
not conjugate, I have to say I strongly prefer the latter. And before
you say it, yes we have to conjugate the verb 'to be' above, but
that's all we'd ever have to conjugate.

···

On 9/28/06, Rick DeNatale <rick.denatale@gmail.com> wrote:

Not that it's going to change, and it's all water long under the bridge, but....

Those predicates are usually part of a larger expression.

We wouldn't say

Give me my nine-iron, if does my bag have my nine-iron.

--
Contribute to RubySpec! @ Welcome to headius.com
Charles Oliver Nutter @ headius.blogspot.com
Ruby User @ ruby.mn

Rick DeNatale wrote:

We wouldn't say

Give me my nine-iron, if does my bag have my nine-iron.

In situ which of these sounds better to the English speaker?

do_something if a.start_with?('foo')
do_something if a.respond_to?(:fred)
do_something if a.include?(:joe)

or

do_something if a.starts_with?('foo')
do_something if a.responds_to?(:fred)
do_something if a.includes?(:joe)

This is probably a consequence of Matz being Japanese. We should be grateful that he used English at all!

And what a beautiful name "DeNatale" is, Napoletano?

Babylon 5 :wink:
Robert

···

On 9/29/06, Rick DeNatale <rick.denatale@gmail.com> wrote:

On 9/28/06, Robert Dober <robert.dober@gmail.com> wrote:

> Aliases are commonly used in Ruby Array#collect, Array#map etc
>
> why not having them for flected forms
> String#starts_with? <=> String#start_with?
> personally I like String#prefix? and String#suffix? too, shorter and
very
> precise.
>
> Object#responds_to? <=> ...
>
> I guess it will make life easier for Newbies and let everybody use it's
> personal feeling for what sounds better.

That was my first thought.

On the other hand it could lead to ethnic enclaves in the ruby
community based on different dialects or accents.

CockneyRuby, SouthernDrawlRuby, LanguedocRuby, SchweizerdeutschRuby? <G>

I used to tell people I met in Zurich that I felt like I was Swiss
since my mother's parents were German, my father's parents were
Italian, et je parle un peu de francais! <G>

--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

--
Deux choses sont infinies : l'univers et la bêtise humaine ; en ce qui
concerne l'univers, je n'en ai pas acquis la certitude absolue.

- Albert Einstein

Rick DeNatale wrote:
> We wouldn't say
>
> Give me my nine-iron, if does my bag have my nine-iron.

In your current form I'd rather use a eight!

> In situ which of these sounds better to the English speaker?
>
> do_something if a.start_with?('foo')
> do_something if a.respond_to?(:fred)

I always found that one troubeling, but I do not consider that a problem,
especially in the light that Matz is Japanese as you pointed ou below, we
too often forget that.

do_something if a.include?(:joe)
>
> or
>
> do_something if a.starts_with?('foo')
> do_something if a.responds_to?(:fred)
> do_something if a.includes?(:joe)

This is probably a consequence of Matz being Japanese. We should be
grateful that he used English at
all!

Amen, and as I said before, after 20 years of Ruby programming I just

mastered method_alias, or was it alias_method (long live ri ;).
Robert

···

On 9/29/06, George <none@none.com> wrote:

--
Deux choses sont infinies : l'univers et la bêtise humaine ; en ce qui
concerne l'univers, je n'en ai pas acquis la certitude absolue.

- Albert Einstein