[#4341] DRY and embedded docs. — Hugh Sasse Staff Elec Eng <hgs@...>
If I have a here document in some ruby program:
[#4347] Re: DATA and rewind. — ts <decoux@...>
>>>>> "H" == Hugh Sasse Staff Elec Eng <hgs@dmu.ac.uk> writes:
[#4350] Re: Thirty-seven Reasons [Hal Fulton] Love[s] Ruby — "David Douthitt" <DDouthitt@...>
[#4396] Re: New Require (was: RAA development ideas (was: RE: Looking for inp ut on a 'links' page)) — Hugh Sasse Staff Elec Eng <hgs@...>
On 9 Aug 2000, Dave Thomas wrote:
[#4411] Re: RAA development ideas (was: RE: Lookin g for inp ut on a 'links' page) — Aleksi Niemel<aleksi.niemela@...>
Me:
On Thu, 10 Aug 2000, [iso-8859-1] Aleksi Niemelwrote:
[#4465] More RubyUnit questions. — Hugh Sasse Staff Elec Eng <hgs@...>
I am beginning to get a feel for this, but I still have a few more
[#4478] Re: RubyUnit. Warnings to be expected? — ts <decoux@...>
>>>>> "H" == Hugh Sasse Staff Elec Eng <hgs@dmu.ac.uk> writes:
[#4481] Invoking an extension after compilation — Dave Thomas <Dave@...>
Hi,
[#4501] What's the biggest Ruby development? — Dave Thomas <Dave@...>
[#4502] methods w/ ! giving nil — Hugh Sasse Staff Elec Eng <hgs@...>
I have got used to the idea that methods that end in '!' return nil if
[#4503] RubyUnit and encapsulation. — Hugh Sasse Staff Elec Eng <hgs@...>
My_class's instance variables are not all "attr :<name>" type variables,
[#4537] Process.wait bug + fix — Brian Fundakowski Feldman <green@...>
If your system uses the rb_waitpid() codepath of rb_f_wait(),
[#4567] Re: What's the biggest Ruby development? — Aleksi Niemel<aleksi.niemela@...>
Dave said:
Robert Feldt <feldt@ce.chalmers.se> writes:
On Sat, 26 Aug 2000, Dave Thomas wrote:
Robert Feldt <feldt@ce.chalmers.se> writes:
On Mon, 28 Aug 2000, Dave Thomas wrote:
Robert Feldt <feldt@ce.chalmers.se> writes:
[#4591] Can't get Tcl/Tk working — Stephen White <steve@...>
I can't get any of the samples in the ext/tk/sample directory working. All
I'm sure looking forwards to buying the book. :)
Stephen White <steve@deaf.org> writes:
On Sun, 27 Aug 2000, Dave Thomas wrote:
Stephen White <steve@deaf.org> writes:
[#4608] Class methods — Mark Slagell <ms@...>
Reading the thread about regexp matches made me wonder about this:
[#4611] mod_ruby 0.1.19 — shreeve@...2s.org (Steve Shreeve)
Shugo (and others),
[#4633] Printing tables — DaVinci <bombadil@...>
Hi.
[#4647] Function argument lists in parentheses? — Toby Hutton <thutton@...>
Hello,
[#4652] Andy and Dave's European Tour 2000 — Dave Thomas <Dave@...>
Hi,
[#4672] calling super from c — Robert Feldt <feldt@...>
[#4699] Double parenthesis — Klaus Spreckelsen <ks@...1.ruhr-uni-bochum.de>
Why is the first line ok, but the second line is not?
[ruby-talk:04365] Re: Thirty-seven Reasons [Hal Fulton]Love[s ] Ruby
Hal:
> > > REASON 21
> > > 21. Reserved words aren't. It's perfectly allowable to use an
> > > identifier that is a so-called "reserved word" as long as the parser
> > > doesn't perceive an amibiguity. This is a breath of fresh air.
David:
> > It is? I don't think anyone should use reserved words as
> > normal variables. A compiler or interpreter writer should
> > almost disallow reserved words as a matter of principle -
> > though in extreme conditions, it might be useful to use them.
Conrad:
> The big gotcha is: "... as long as the parser doesn't perceive an
> ambiguity.". This gives the usability of this feature a somewhat
> counter-intuitive Perl-like dependency on context. If you had a (say
> "AI") program that dynamically generated Ruby code that
> turned incoming
> text words (say with _a_ being substituted for apostrophes and so on)
> into variable names, your code would likely be sooner or later tripped
> up by this feature.
Well, I have to say I'm standing with Hal here. What isn't restricted does
not have to be done. No one keeps you from jumping over the edge on high and
steep mountain, but most of the time you wouldn't do it. Sometimes you
*want* to do it, and it's nice no one has built a net to catch you. If I'd
like BASE jumping very much, I'd consider finding that net builder and let
him test his nets personally...
But back to the real life, and about the code Hal has written himself at
http://www.hypermetrics.com/rubyset.html (snippet):
class Object # Why has to be outside module?
def in(x)
x.include? self
end
end
This code allows him to write
def test_member_01
x = Set(2,3,4)
(2.in x) && (3.in x) && (4.in x)
end
Yet 'in' is a reserved word as there's for-in construct and parse.y defines
explicitly kIN.
I agree that most of the time you would not like to do this, and it
prohibits easy ways to grep sources. OTOH, I guess this example is handled
well by emacs, as it probably detects the name of the method at least in two
different ways; def method_name and obj.method_name.
IMO, on some cases there really is no ambiguity what the code means, and the
simplest cases of those should be exploitable.
This actually goes nicely along with the naming conventions. The language is
of course a set of language rules, but it's also a set of more or less
standard conventions. These conventions include caSIng, accompanied test
suite, location of libraries. Some languages miss some features I consider
crucial, but no language contain all, as many times conventions counteract
or are simply contradictory.
Standard naming is defined for Java for example, but it's not forced. That
naming is actually quite much the same as in Ruby (the principle of
least...) and in many other major languages nowadays. Java defines also
reserved words, and *forces* they are not used as identifiers.
Well, Ruby simply takes different approach. It forces something about
naming, and does not force one not to mess up with reserved words - when
possible. I'd like to free up the name forcing too, trusting on a developer.
But here's a catch. We get something when trading off freedom of
individually styled naming. We don't have to find out where the variable
should be defined. It's global if has '$', it may be a CONSTANT, or
@instance_variable or @@class_variable.
Surely @attribute is easier to write than self.attribute. But if you think
latter is so much more beautiful, use latter (and define the accessors,
which is good idea anyway :). If you can stand being a little bit ambiguate
use plain 'attribute'.
Please reconsider the last paragraph, look again which was the only case I
had to explicitly mark which part of the sentence is 'code' :).
However, while it might sound I'm quite much pro Ruby, I'd like to give up
some forcing. One might be able to do like this:
global :foo
def bar
puts foo
end
And when Ruby is checking out what the foo might be inside bar, it sees
there's only global definition, and applies that. If this is good, it's hard
to say, as adding foo variable somewhere might confuse things up. So if you
really want to say 'puts $foo' it's explicitly expressed this way.
- Aleksi