Ruby Language Q's

Ahh. But then, constants aren’t method calls, so
why doesn’t something like this work:

irb(main):002:0> FalseClass ? 0 : 1
0

No surprise, right? Then why does this happen:

irb(main):003:0> FalseClass?0:1    
SyntaxError: compile error
(irb):3: parse error
FalseClass?0:1
             ^
        from (irb):3

The compiler should know that FalseClass is a constant and
therefore isn’t a method call, so the “?” is the operator
and should be a seperate token.

– Dossy

···

On 2002.08.13, ts decoux@moulon.inra.fr wrote:

There IS no method #1? defined.

in 1?true:false' 1’ is interpreted as a Fixnum


Dossy Shiobara mail: dossy@panoptic.com
Panoptic Computer Network web: http://www.panoptic.com/
“He realized the fastest way to change is to laugh at your own
folly – then you can let go and quickly move on.” (p. 70)

we could write interfaces like

  drawWidget fred   x: 10   y: 20  color: red

The Ruby Tk constructors could replace the current instance_eval trick
with this syntax and lose the confusing scoping rules.

This looks nice. Only thing is the havoc one could write
with the ? operator, and Symbols:-

 wossname a: 3 b: r ? x : y c: :d

but then anything can be obfuscated… Is this frightening enough to
require some other form? The chances of anyone writing real code like
that compare to a Snowball in hell, so I’m just playing Devil’s Advocaat
here…:slight_smile:

Just an idea…

Dave

    Hugh
···

On Wed, 31 Jul 2002, Dave Thomas wrote:

complete change of the Ruby source; you need only change the Init_*

                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

???

Guy Decoux

Is it just me, or is anyone else getting a multitude of duplicate
posts from Justin?

···

— Justin Johnson justinj@mobiusent.com wrote:

=====

Use your computer to help find a cure for cancer: http://members.ud.com/projects/cancer/

Yahoo IM: michael_s_campbell


Do You Yahoo!?
Yahoo! Health - Feel better, live better

“Hal E. Fulton” hal9000@hypermetrics.com writes:

puts(a = “hello”)

Are you saying you disapprove of this choice for named parameters?
If you disapprove, I agree. If you approve, I disagree. Confused
yet? (If you don’t approve, I can’t help but refrain from not
disagreeing.)

Sorry - my typing’s getting worse. I disapprove of ‘=’, approve of
‘:’, even more so if the comma is optional before a ‘name:’ symbol.

Dave

“Dave Thomas” Dave@PragmaticProgrammer.com wrote in message
news:m2ptx58b0m.fsf@zip.local.thomases.com

ts decoux@moulon.inra.fr writes:

  drawWidget fred   x: 10   y: 20  color: red

You should also be aware of the syntax for possible type annotations that
could be added in the future to help a compiler, as is the case in Dylan as
I recall.

Mikkel

Hi,

we could write interfaces like

 drawWidget fred   x: 10   y: 20  color: red

Removing commas make programs look more like Smalltalk, but it will
make the language something but Ruby.

Dave, you have asked me once about the secret of Ruby’s good design.
I answered then, I didn’t know. I didn’t even know why others did not
come out with their languages just as good as Ruby.

I think I now understand the secret. It’s “style”, and from what I’ve
learned recently, the “style” is the most difficult word in English,
probably in other human languages too.

						matz.
···

In message “Re: Ruby Language Q’s” on 02/07/31, Dave Thomas Dave@PragmaticProgrammer.com writes:

The compiler should know that FalseClass is a constant and
therefore isn't a method call, so the "?" is the operator
and should be a seperate token.

Forgotten the method Kernel#Integer :slight_smile:

pigeon% ruby -e 'def FalseClass?() p "FalseClass"; end; FalseClass?'
"FalseClass"
pigeon%

Guy Decoux

Hi –

There IS no method #1? defined.

in 1?true:false' 1’ is interpreted as a Fixnum

Ahh. But then, constants aren’t method calls, so
why doesn’t something like this work:

irb(main):002:0> FalseClass ? 0 : 1
0

No surprise, right? Then why does this happen:

irb(main):003:0> FalseClass?0:1
SyntaxError: compile error
(irb):3: parse error
FalseClass?0:1
             ^
        from (irb):3

The compiler should know that FalseClass is a constant and
therefore isn’t a method call, so the “?” is the operator
and should be a seperate token.

I’m not sure why, but one can do this:

irb(main):023:0> def WeirdName? ; puts “hi” ; end
nil
irb(main):024:0> WeirdName?
hi

i.e., Konstant? can be a method name.

David

···

On Tue, 13 Aug 2002, Dossy wrote:

On 2002.08.13, ts decoux@moulon.inra.fr wrote:


David Alan Black
home: dblack@candle.superlink.net
work: blackdav@shu.edu
Web: http://pirate.shu.edu/~blackdav

class Test
def AMethod?
puts “Ho Ho HO”
end
end
a = Test.new
a.AMethod?

It could be a method (maybe to be defined later), and Ruby seems to
take it as such…
If Ruby had to check whether a constant exists already or not, the
language would no longer be context-free.

···

On Tue, Aug 13, 2002 at 01:15:11AM +0900, Dossy wrote:

No surprise, right? Then why does this happen:

irb(main):003:0> FalseClass?0:1    
SyntaxError: compile error
(irb):3: parse error
FalseClass?0:1
             ^
        from (irb):3

The compiler should know that FalseClass is a constant and
therefore isn’t a method call, so the “?” is the operator
and should be a seperate token.


_ _

__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_ _ \ / ` | ’ \
) | (| | |
__ \ | | | | | (| | | | |
.__/ _,
|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

(It is an old Debian tradition to leave at least twice a year …)
– Sven Rudolph

Are you asking my why I am saying this or what I mean by Init_*?

Paul

···

On Wed, Jul 31, 2002 at 01:46:08AM +0900, ts wrote:

complete change of the Ruby source; you need only change the Init_*
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

???

Hi,

we could write interfaces like

 drawWidget fred   x: 10   y: 20  color: red

Removing commas make programs look more like Smalltalk, but it will
make the language something but Ruby.

Dave, you have asked me once about the secret of Ruby’s good design.
I answered then, I didn’t know. I didn’t even know why others did not
come out with their languages just as good as Ruby.

I think I now understand the secret. It’s “style”, and from what I’ve
learned recently, the “style” is the most difficult word in English,
probably in other human languages too.

If I attempted to quantify Ruby’s “style”, I would probably paraphrase
(plagarize?) the introductions of several Ruby books and call it
flexible and legible, yet terse. Flexible, because of the adherence to
POLS as a design principle, gratuitous method aliasing both in the core
libraries and many well-written modules, and syntax which allows you to
chain operations via OO or logic operators.a Legible, because Ruby is
free of the pointless casting nonsense that pollutes other high-level
languages, because variable prefixes allow you to quickly determine
scop, and because thorough use of closures encourage simple encapsulated
code blocks. Terse, because unlike other languages, Ruby’s shortcuts,
such as built-in regular expression support and omitting semicolons,
rarely come at the expense of flexibility or legibility.

Of course, style is entirely subjective by nature, and I’m sure everyone
else has their own ideas about Ruby’s “style”.

···

In message “Re: Ruby Language Q’s” > on 02/07/31, Dave Thomas Dave@PragmaticProgrammer.com writes:

  					matz.


Paul Duncan pabs@pablotron.org pabs in #gah (OPN IRC)
http://www.pablotron.org/ OpenPGP Key ID: 0x82C29562

Matz’s next book is “Feng Shui for Computer Programming Languages”.

:stuck_out_tongue:

– Dossy

···

On 2002.07.31, Yukihiro Matsumoto matz@ruby-lang.org wrote:

Dave, you have asked me once about the secret of Ruby’s good design.
I answered then, I didn’t know. I didn’t even know why others did not
come out with their languages just as good as Ruby.

I think I now understand the secret. It’s “style”, and from what I’ve
learned recently, the “style” is the most difficult word in English,
probably in other human languages too.


Dossy Shiobara mail: dossy@panoptic.com
Panoptic Computer Network web: http://www.panoptic.com/
“He realized the fastest way to change is to laugh at your own
folly – then you can let go and quickly move on.” (p. 70)

Forgotten the method Kernel#Integer :slight_smile:

Didn’t forget, just puzzled by the breakage of “all initially capitalizezd
symbols are constants” … :wink:

···

On 2002.08.13, ts decoux@moulon.inra.fr wrote:

On 2002.08.13, dblack@candle.superlink.net dblack@candle.superlink.net wrote:

i.e., Konstant? can be a method name.

Right. Not what I would have expected.

– Dossy


Dossy Shiobara mail: dossy@panoptic.com
Panoptic Computer Network web: http://www.panoptic.com/
“He realized the fastest way to change is to laugh at your own
folly – then you can let go and quickly move on.” (p. 70)

complete change of the Ruby source; you need only change the Init_*
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

???

Are you asking my why I am saying this or what I mean by Init_*?

He’s saying changing the Init_* methods is a complete change of the Ruby
source.

···

On Wed, Jul 31, 2002 at 01:46:08AM +0900, ts wrote:

Paul


Paul Duncan pabs@pablotron.org pabs in #gah (OPN IRC)
http://www.pablotron.org/ OpenPGP Key ID: 0x82C29562

If you really think that you can add named parameter with modifying *only*
the Init_* in the source of ruby than I think that perhaps you must look
at this source ...

Guy Decoux

···

On Wed, Jul 31, 2002 at 01:46:08AM +0900, ts wrote:

complete change of the Ruby source; you need only change the Init_*

                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

???

Are you asking my why I am saying this or what I mean by Init_*?