parts of speech in Ruby

C

Chad Perrin

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?
 
7

7stud --

Chad said:
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
 
J

Jason Perkins

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/Linking_verb>

--
Jason Perkins
(e-mail address removed)

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

-Jon Bentley and Doug McIlroy
 
J

Jason Perkins

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

<http://en.wikipedia.org/wiki/Linking_verb>

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

--
Jason Perkins
(e-mail address removed)

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

-Mitch Ratcliffe
 
M

Morton Goldberg

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.wikipedia.org/
wiki/Copula>.

Regards, Morton
 
T

Todd Benson

I think it might be consider a copula. See <http://en.wikipedia.org/
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

M. Edward (Ed) Borasky

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

<http://en.wikipedia.org/wiki/Linking_verb>

--
Jason Perkins
(e-mail address removed)

"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".
 
M

Morton Goldberg

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
 
S

Shai Rosenfeld

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
 
R

Randy Kramer

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
 
T

Todd Benson

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
 
M

Morton Goldberg

Okay . . . so what programming language syntactic element is
analogous to
a coupla?

verb = method
noun = object
coupla = ?

I am suggesting, very tentatively, that

copula = variable binding

Regards, Morton
 

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,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top