[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

parts of speech in Ruby

Chad Perrin

10/8/2007 9:44:00 PM

I'm curious -- exactly what class of syntactic element is `=` in Ruby,
where "class of syntactic element" is roughly analogous to "part of
speech". If objects are nouns and methods are verbs, that means `=` is
neither a noun nor a verb. Is it a participle? Is it punctuation? If
it's a participle, I'd like to know what class of syntactic element that
is in Ruby. If it's punctuation, I'd like some explanation for how that
works conceptually -- because I think of punctuation in Ruby as being
stuff like the parentheses around a method argument.

Anyone? Bueller?

--
CCD CopyWrite Chad Perrin [ http://ccd.ap... ]
Kent Beck: "I always knew that one day Smalltalk would replace Java. I
just didn't know it would be called Ruby."

12 Answers

7stud 7stud

10/8/2007 10:14:00 PM

0

Chad Perrin wrote:
> If objects are nouns and methods are verbs


class Dog
attr_accessor :bite

#define = method:
def bite=(str)
@bite = str
end

end

d = Dog.new
d.bite = "worse than my bark"
puts d.bite
--
Posted via http://www.ruby-....

Jason N.Perkins

10/8/2007 11:43:00 PM

0


On Oct 8, 2007, at 4:44 PM, Chad Perrin wrote:

> I'm curious -- exactly what class of syntactic element is `=` in Ruby,
> where "class of syntactic element" is roughly analogous to "part of
> speech". If objects are nouns and methods are verbs, that means
> `=` is
> neither a noun nor a verb. Is it a participle? Is it
> punctuation? If
> it's a participle, I'd like to know what class of syntactic element
> that
> is in Ruby. If it's punctuation, I'd like some explanation for how
> that
> works conceptually -- because I think of punctuation in Ruby as being
> stuff like the parentheses around a method argument.
>
> Anyone? Bueller?

Wouldn't it be a linking verb, such as 'is'?

<http://en.wikipedia.org/wiki/Linkin...

--
Jason Perkins
jperkins@sneer.org

"The key to performance is elegance, not
battalions of special cases."

-Jon Bentley and Doug McIlroy



Jason N.Perkins

10/9/2007 12:10:00 AM

0


On Oct 8, 2007, at 6:42 PM, Jason Perkins wrote:

>
> On Oct 8, 2007, at 4:44 PM, Chad Perrin wrote:
>
>> I'm curious -- exactly what class of syntactic element is `=` in
>> Ruby,
>> where "class of syntactic element" is roughly analogous to "part of
>> speech". If objects are nouns and methods are verbs, that means
>> `=` is
>> neither a noun nor a verb. Is it a participle? Is it
>> punctuation? If
>> it's a participle, I'd like to know what class of syntactic
>> element that
>> is in Ruby. If it's punctuation, I'd like some explanation for
>> how that
>> works conceptually -- because I think of punctuation in Ruby as being
>> stuff like the parentheses around a method argument.
>>
>> Anyone? Bueller?
>
> Wouldn't it be a linking verb, such as 'is'?
>
> <http://en.wikipedia.org/wiki/Linkin...

FWIW, I've read that modules can be considered adjectives, which fits
in nicely with what you're doing.

--
Jason Perkins
jperkins@sneer.org

"The computer allows you to make mistakes
faster than any other invention, with the
possible exception of handguns and tequila."

-Mitch Ratcliffe



Morton Goldberg

10/9/2007 1:33:00 AM

0

On Oct 8, 2007, at 5:44 PM, Chad Perrin wrote:

> I'm curious -- exactly what class of syntactic element is `=` in Ruby,
> where "class of syntactic element" is roughly analogous to "part of
> speech". If objects are nouns and methods are verbs, that means
> `=` is
> neither a noun nor a verb. Is it a participle? Is it
> punctuation? If
> it's a participle, I'd like to know what class of syntactic element
> that
> is in Ruby. If it's punctuation, I'd like some explanation for how
> that
> works conceptually -- because I think of punctuation in Ruby as being
> stuff like the parentheses around a method argument.
>
> Anyone? Bueller?

I think it might be consider a copula. See <http://en.wiki...
wiki/Copula>.

Regards, Morton

Todd Benson

10/9/2007 2:28:00 AM

0

On 10/8/07, Morton Goldberg <m_goldberg@ameritech.net> wrote:
> On Oct 8, 2007, at 5:44 PM, Chad Perrin wrote:
>
> > I'm curious -- exactly what class of syntactic element is `=` in Ruby,
> > where "class of syntactic element" is roughly analogous to "part of
> > speech". If objects are nouns and methods are verbs, that means
> > `=` is
> > neither a noun nor a verb. Is it a participle? Is it
> > punctuation? If
> > it's a participle, I'd like to know what class of syntactic element
> > that
> > is in Ruby. If it's punctuation, I'd like some explanation for how
> > that
> > works conceptually -- because I think of punctuation in Ruby as being
> > stuff like the parentheses around a method argument.
> >
> > Anyone? Bueller?
>
> I think it might be consider a copula. See <http://en.wiki...
> wiki/Copula>.
>
> Regards, Morton

I agree with Morton a little here, since "a = b" doesn't necessarily
mean "a is b".

I suppose it's all about how far you want to take it conceptually.
Like, for example, in my head I see "a = b" as "a tries to put on b's
shoes", or to make it more short, something like, "b marries a".

In another language, that might sound more like "b, a, they become
together for a while".

For all simplicity, though, I guess the copula term could best
describe it for the English language.

Not a straight answer, but, there you go.

class C
def []= something
puts "hello"
end
end

b = C.new[] = "hola"

The semantics break down when you look at a single symbol (in this
case, '=') and try to replace it with a word (be it verb, transitive,
cupola or otherwise).

I don't know your use case, but I think it's impossible to translate a
programming language into a spoken one. I would be fascinated if you
could prove me wrong though.

Todd

M. Edward (Ed) Borasky

10/9/2007 2:38:00 AM

0

Jason Perkins wrote:
>
> On Oct 8, 2007, at 4:44 PM, Chad Perrin wrote:
>
>> I'm curious -- exactly what class of syntactic element is `=` in Ruby,
>> where "class of syntactic element" is roughly analogous to "part of
>> speech". If objects are nouns and methods are verbs, that means `=` is
>> neither a noun nor a verb. Is it a participle? Is it punctuation? If
>> it's a participle, I'd like to know what class of syntactic element that
>> is in Ruby. If it's punctuation, I'd like some explanation for how that
>> works conceptually -- because I think of punctuation in Ruby as being
>> stuff like the parentheses around a method argument.
>>
>> Anyone? Bueller?
>
> Wouldn't it be a linking verb, such as 'is'?
>
> <http://en.wikipedia.org/wiki/Linkin...
>
> --
> Jason Perkins
> jperkins@sneer.org
>
> "The key to performance is elegance, not
> battalions of special cases."
>
> -Jon Bentley and Doug McIlroy
>
>
>
>

In Pascal, "a := b" is normally read as "a becomes b". So in Ruby, I
would translate "a = b" as "a becomes a reference to b".

Morton Goldberg

10/9/2007 4:46:00 AM

0

On Oct 8, 2007, at 10:38 PM, M. Edward (Ed) Borasky wrote:

> In Pascal, "a := b" is normally read as "a becomes b". So in Ruby,
> I would translate "a = b" as "a becomes a reference to b".

It's more "a becomes a reference to the object b is referencing", or
better yet "a is now bound to the same object as b [is bound to]". My
suggestion identifying "=" with the English copula is very tentative.
It's probably futile to try to force English syntactic terminology
onto Ruby.

Regards, Morton

Shai Rosenfeld

10/9/2007 9:25:00 AM

0

> I don't know your use case, but I think it's impossible to translate a
> programming language into a spoken one. I would be fascinated if you
> could prove me wrong though.
>
> Todd

chad.convert2lang(code) ? tod=fascinated : tod=right

;) really would be fascinating though
--
Posted via http://www.ruby-....

Randy Kramer

10/9/2007 11:43:00 AM

0

On Tuesday 09 October 2007 12:45 am, Morton Goldberg wrote:
> On Oct 8, 2007, at 10:38 PM, M. Edward (Ed) Borasky wrote:
>
> > In Pascal, "a := b" is normally read as "a becomes b". So in Ruby,
> > I would translate "a = b" as "a becomes a reference to b".
>
> It's more "a becomes a reference to the object b is referencing", or
> better yet "a is now bound to the same object as b [is bound to]". My
> suggestion identifying "=" with the English copula is very tentative.
> It's probably futile to try to force English syntactic terminology
> onto Ruby.

(A newbie (or slow learning oldbie) lurker chiming in): If you're a *nix
user, a way of thinking about it that seems to help me (because I think now I
finally am beginning to understand it) is as analogous to a hard link in
Linux--a and b are alternate names for an object, and a = b is the act of
creating the alternate name a.

So maybe (I'm thinking about this) I'd read a = b as one of:

* create a new name a for b
* (hard) link a to b
* ???

(I call it a hard link instead of a soft link because I think the hard link is
a closer analogy.)

Randy Kramer

Todd Benson

10/9/2007 2:01:00 PM

0

On 10/9/07, Shai Rosenfeld <shaiguitar@gmail.com> wrote:
> > I don't know your use case, but I think it's impossible to translate a
> > programming language into a spoken one. I would be fascinated if you
> > could prove me wrong though.
> >
> > Todd
>
> chad.convert2lang(code) ? tod=fascinated : tod=right
>
> ;) really would be fascinating though

Ouch. That hurts the feelings a little bit, but it makes for a good joke :)

How about (which is not a joke)...

ruby.convert2reason( tod ) ? ros = fascinated : ros = right

I'm pretty mature when it comes to open forums, but I have to be
honest (again), in this one I just can't figure people out. Maybe
that's a good thing?

Todd