Dave T. wrote:
contain a complete list of operators. I’ve done everything I can
think of to find it. I seriously doubt that it’s there. The
precedence table on 324 is about precedence, and not a primary
presentation of operators and their function.
Which methods/operators are missing from the precedence table? I’ll
add them.
Oh, man…now I’ve going to have to get rigorous in my consideration of
the topic, aren’t I? Heh heh. Probably about time, too. So…I’ll go on
a search and recover mission, if only for my own edification. If I find
anything, I’ll report back. Probably will anyway.
But to me the basic problem with the p. 324 table, as I suggested, is
that its subject is about precedence - a completely legitimate subject -
and is NOT primarily a presentation of operators with an explication of
what they DO. THAT’s what I looked for practically the first time I
encountered the book, and have been looking for ever since.
As I just said in a response to Todd’s post, The best presentation of
Ruby operators I’ve yet found (looking mostly on the web) is at
Ruby - Operators. THIS is the sort
of presentation I expect in ANY language book. It seems fully as basic
as a definition of what a variable is and how one works, along with all
the other basic building blocks of the language. Languages are build up
from primitives - analogous to the premises in a logical argument. If
the premises are unclear, the argument cannot go forward, and that’s
been exactly my experience with Ruby. I encounter some strange operator
- like the “?” encounter I had last night, and I want to go read about
this thing. After well over 30 minutes search through quite a range of
material, I had found next to nothing. That’s nuts, to me.
?, tho’ is not an operator, any more than the quote is in “cat”
or the slash in /cat/. In all three cases they’re simply syntax for
literals.
I’m still struggling here. When syntax is productive of something, I see
an operation occurring - active functionality. I’m perfectly content to
see operators as methods. Syntactically there’s no problem that I can
detect in that construct. But to call “?” a literal…well, I must
go study up a bit on this. To me, “abcdef” is a literal. ‘\n’ is too.
“\n” is a literal if you allow meaning to be contexturalized, which
should be no problem. As input to various processes, ‘\n’ and “\n” have
different outcomes, but by themselves produce nothing. “?”
produces something. Irb makes this clear (to me):
irb(main):006:0> puts ‘\n’
\n
=> nil
irb(main):007:0> puts “\n”
=> nil
irb(main):008:0> puts ?\n
10
=> nil
irb(main):009:0>
If in “-1”, we consider the “-” to be an operator, then I see an exact
parallel to the function of “?a”.
It’s not the same as what quote marks do - THEY provide context, and
change meaning. Operators PRODUCE something. They “operate”. It seems
very simple. If I’m making a fundamental error, I’d be very grateful to
have it point out to me. I highly value arriving at a place of clear
understanding, when it’s possible.
this for a long time.
Let me know what to add, and I’ll definitely consider adding it. But
be aware that I don’t really consider the concept of “an operator” to
be particular primary in the description of the language, because in
Ruby there’ll always be debate about just what is an operator. The
precedence table is my best take on it—I derived it from the parser,
and I believe it contains every operator-like thing I could find in
there. But, as I said, I’d love to hear suggestions, as the third
edition is nearing completion, and I’m always open for ideas to make
it better.
Dave, the function descriptions in this table are too minimal, I think.
Not enough for a beginner - not for this one, anyway, and Ruby is at
least the fifth language I’ve dug around in. In all the others (Fortran,
APL, Pascal/Delphi, Basic, Python, a tabular presentation of the
operators the languages recognizes was shown to me EARLY, and I always
found it highly informative, since it told me what I could DO with
primitive units of data. Seems like an excellent starting point for more
complex topics.
Your comment about the operator concept is very interesting. I think
that it would be really, truly helpful for you to lay out Ruby more from
the ground up - shown me clearly it fundamental components, beginning
with the ‘primitives’ - reserved words are primitives, and so are
variables, etc. Operators, too, I’d say. From these things we build
other things, like data containers - meta-primitives, if you will.
I have always been greatly bewildered that in your book (I’m looking at
2nd edition PDF again), we’re into arrays and hashes on p. 14 and I have
to encounter anything substantive about operators - those things that
glue together variables and constants so that we can form expressions.
Maybe I just bring the wrong mindset to Ruby. I’m willing to be told
that, if I’m shown a better one. However, I’d bet that a great many of
us did study grammar in school (remember “parts of speech”?), and some
of us have studied linguistics, and many of us have at least dabbled in
other languages. There are conventions about how we talk about human
communication, in general, computer languages included. When I come to a
presentation of a new language, the first thing I look for is the
familiar. I want some secure ground I can readily claim (“oh, I know
what THAT is!”), so that I can move from that out into the wilderness of
new territory.
For me that secure ground in anything of linguistic nature will always
be the “meme” concept - in formal linguistics this would be an analysis
of phonemes (aural primitives - irreducible units of sound) and
graphemes (irreducible units of sound representation), etc. None of
these concepts are perfect, but they ARE plainly very useful. The basic
model is very familiar: premises (or data, if you will) + logic (legal
operations) = argument (or assertion or expression). This model is a
part of our cultural memory, as it were.
I want someone to show me the pieces of something, and how they go
together. I don’t want complexity until I grasp the little things, at
least at the conceptual, if not the operational/functional, level. I
love the highly informative narratives you lay out in your book, about
all manner of topics. But I’m bewildered that in Ch. 2, the first real
content about the language per se, we’re right away talking about OO
programming. I don’t yet have the pieces of the language, at this point.
How can I think about how OO programming is done in Ruby. It’s as if I’m
being asked to walk on air. Obviously, this is just one man’s reaction,
and I full well know you’ll see it that way. No problem.
If ANY of this is of any use to you in any way, it’s worth the time it
took for me to lay it out. I don’t expect a response. I’m only hoping
that maybe some of my perspective might be useful to you. If you get a
chance to read it at all, I’m content simply with that.
3rd edition coming out soon, eh? I have to say that one of the great
joys of being in the Ruby community is that the future looks so
interesting - and this is one piece of it we can all look forward to.
I’m sure you’ll have my money soon enough, and it’ll be a bargain! Best
of luck with your work on this project, and my thanks as well.
Thanks…
Tom
Cheers
Dave
–
Tom C., MS MA, LMHC - Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< [email protected] >> (email)
<< TomCloyd.com >> (website)
<< sleightmind.wordpress.com >> (mental health weblog)