Syntax "surprise"

Thanks, but I had lots of help from lots of other smart folks.

···

At 4:32 AM +0900 7/18/02, Ned Konz wrote:

On Wednesday 17 July 2002 10:48 am, Christopher Browne wrote:

I seem to recall Objective C having a pretty nice approach to it,
too. (Somehow your name tickles some memories concerning ObjC…
You didn’t have some involvement with it, did you?)

Brad Cox wrote Objective C.


Brad Cox, PhD; bcox@virtualschool.edu 703 361 4751
o For industrial age goods there were checks and credit cards.
For everything else there is http://virtualschool.edu/mybank
o Interactive Learning Environment http://virtualschool.edu/ile
o Java Web Application Architecture: http://virtualschool.edu/jwaa

Brad Cox wrote:

Didn’t mention keywords because that’s really the best tool for this
job, but unsupported in ruby. When that’s fixed I’ll withdraw my
objection.

It’s pretty near supported, though:
(From my Evas-Ruby[1] docs:)

text = evas.new_text(
:x => 100, :y => 100,
:fontname => “Verdana_Bold”, :fontsize => 10,
:text => “Evas test succeeded!”
)

And in a hash you can use the extra comma.

Tim Hunter wrote:

C allows a trailing comma in initializers:

int foo = {1,2,3,};

And Ruby has the same style in initializers.
But even C doesn’t allow you to call functions like that:
printf(“hello %d”, 23,);

[1] http://neugierig.org/software/ruby/evas/evas.html

Ruby with Objective-C’s message syntax? Now that’s something I could
really get behind… we could change the block syntax from {} to
while we’re at it, get rid of control structures in favor of methods
like ifTrue:ifFalse:, build a class browser or two, and we’d have a
great little language :wink:

Seriously, though, I’m curious - how did you end up at Ruby instead
of, say, Squeak? Clearly not for syntax reasons. I enjoy developing
in Ruby, Smalltalk, and Objective-C about equally (they all share the
One True Object Model, after all), but I sure do miss keyword
selectors in Ruby…

Cheers,
Avi

···

Brad Cox bcox@virtualschool.edu wrote

Didn’t mention keywords because that’s really the best tool for this
job, but unsupported in ruby. When that’s fixed I’ll withdraw my
objection.

The following is a common idiom:

foo("this is a really long string. in fact, it is so long "
“that I have to wrap onto multiple lines.”)

Paul

···

On Wed, Jul 24, 2002 at 12:46:37AM +0900, Mike Hall wrote:

  • compile time string concatenation, “hello” “world” => “helloworld”

I know that some other popular languages like to do that,
but I think it would be better to leave it as two arguments.
After all, someone wrote those two literals separately on purpose.

Wouldn’t this add a significant amount of ambiguity and confusion? what if a
is a function that takes two arguments? what if the second is optional? etc
etc. In a language like ruby this would be a surprise, at least to me. It
also implies that there is currying going on when there isn’t, at least to
users of things like ml and haskell (though if there was, it might mitigate the
confusion - and be less and less like ruby).

-kyle

···

On Wed, Jul 24, 2002 at 12:46:37AM +0900, Mike Hall wrote:

obj.method a, b, c {|i| xyz}
vs
obj.method a b c {|i| xyz}


moved

and everybody wants to know you is rapt like moon river then
beyond the blinds

Hi,

···

In message “Re: Syntax “surprise”” on 02/07/24, Mike Hall mghall@enteract.com writes:

I noticed this in the 1.6.7 TODO file:

  • compile time string concatenation, “hello” “world” => “helloworld”

You already have this feature (note: item with “-” is done). But I
admit I shouldn’t have. It is source of confusion rather than
usefulness. The far future Ruby will not have this feature, maybe.

						matz.

Ruby with Objective-C’s message syntax? Now that’s something I could
really get behind… we could change the block syntax from {} to
while we’re at it, get rid of control structures in favor of methods
like ifTrue:ifFalse:, build a class browser or two, and we’d have a
great little language :wink:

While we’re picking syntactic nits, how about replacing begin…end with
{…} throughout? I rely on vim parentheses matching heavily and
begin–end removes this indispensible cruth.

Seriously, though, I’m curious - how did you end up at Ruby instead
of, say, Squeak? Clearly not for syntax reasons. I enjoy developing
in Ruby, Smalltalk, and Objective-C about equally (they all share the
One True Object Model, after all), but I sure do miss keyword
selectors in Ruby…

I wouldn’t say I’ve “ended up” with any particular tool, any more
than a carpenter “ends up” with a particular saw. I keep lots of
tools around and choose the right one for the job.

See http://virtualschool.edu/ile/tut/Pages/Background/HistoryPage for
why I picked ruby for the interactive learning environment project.
The biggest single reason was its #{…} string escape sequence,
which was unobtrusive and understandable even to nonprogrammers.
Mainly dropped python for this very reason. See
http://virtualschool.edujwaa/demo/JwaaMLS for the nonsense I had to
go through to do something similar in java.

Please pardon the typos; they are fixed in the next release.

···

At 7:48 AM +0900 7/18/02, Avi Bryant wrote:

Brad Cox, PhD; bcox@virtualschool.edu 703 361 4751
o For industrial age goods there were checks and credit cards.
For everything else there is http://virtualschool.edu/mybank
o Interactive Learning Environment http://virtualschool.edu/ile
o Java Web Application Architecture: http://virtualschool.edu/jwaa

Hi,

···

In message “Re: Syntax “surprise”” on 02/07/18, Brad Cox bcox@virtualschool.edu writes:

Brad Cox wrote Objective C.

Thanks, but I had lots of help from lots of other smart folks.

That’s the way languages are designed. You smart people are helping
me now. Brad, I bought your book. It is my greatest astonishment for
years that I found you here. Thanks.

						matz.

Ruby with Objective-C’s message syntax? Now that’s something I could
really get behind… we could change the block syntax from {} to
while we’re at it, get rid of control structures in favor of methods
like ifTrue:ifFalse:, build a class browser or two, and we’d have a
great little language :wink:

A few postings elsewhere have given examples of getting something that’s
similar to Objective-C’s (and SmallTalks) message syntax. Like a few other
people here, I think that naming message parameters can improve readability.
I wonder if it would at all be worth considering a little syntactic sugar
for this?

obj.my_method( :x => 10, :y => 20, :z => 30 )

sweetened to:

obj.my_method( x: 10, y: 20, z: 30 )

where the ‘:’ at the end of a parameter var really treats the var name as a
symbol and behaves as though it’s followed by a ‘=>’.

Look neat to me. What does anybody else think?

I think the blocks use {} because they are more familiar to many
programmers. After first looking at SmallTalk, I found the for blocks
strange until I got used to it. are used often for indexing in lots of
other languages.

Hey, wait a minute…are you trying to turn Ruby into SmallTalk? :o)

···


Justin Johnson

Paul Brannan pbrannan@atdesk.com writes:

···

On Wed, Jul 24, 2002 at 12:46:37AM +0900, Mike Hall wrote:

  • compile time string concatenation, “hello” “world” => “helloworld”

I know that some other popular languages like to do that,
but I think it would be better to leave it as two arguments.
After all, someone wrote those two literals separately on purpose.

The following is a common idiom:

foo("this is a really long string. in fact, it is so long "
“that I have to wrap onto multiple lines.”)

or

foo("this is short\

and so is this")

The string would include the newline.

Jim

Jim Menard, jimm@io.com, http://www.io.com/~jimm/
“Anyone else picturing Wallace sitting in front of a Rube Goldburgesque
workstation, accidentally booting up Netscape and crying out, ‘It’s the
wrong browser, Grommit!’ ?” – Jim Evans in rec.humor.oracle.d

i agree. you can’t get rid of the commas. that would really confuse
things.

method1 arg1 arg2, arg3 method2 argA, argB argC

whats the method precedence? or is it list? i’d get lost quick. ever
tried programming in rebol. yuk!

on the other hand, i never quite got why blocks ended up on the outside
of the arguments. is it just for nice syntax? seems to me by putting
them on the outside we’ve limited ourselves to one block (though you can
get around this):

iterator_method (arg) {...block...}  ?

	vs.

iterator_method (arg, {...block...}, {...another block...})

of course hashes and blocks using the same deliminator is probably
partly to do with it too.

~transami

···

On Tue, 2002-07-23 at 15:09, Kyle Rawlins wrote:

On Wed, Jul 24, 2002 at 12:46:37AM +0900, Mike Hall wrote:

obj.method a, b, c {|i| xyz}

vs
obj.method a b c {|i| xyz}

Wouldn’t this add a significant amount of ambiguity and confusion? what if a
is a function that takes two arguments? what if the second is optional? etc
etc. In a language like ruby this would be a surprise, at least to me. It
also implies that there is currying going on when there isn’t, at least to
users of things like ml and haskell (though if there was, it might mitigate the
confusion - and be less and less like ruby).

-kyle


moved

and everybody wants to know you is rapt like moon river then
beyond the blinds

~transami

Kyle Rawlins wrote:

  obj.method a, b, c {|i| xyz}

vs
obj.method a b c {|i| xyz}

Wouldn’t this add a significant amount of ambiguity and confusion? what if a
is a function that takes two arguments? what if the second is optional?

Don’t we have the same problem now, with commas?
We “solve” it with parens to group the arguments
and to clearly specify who goes with what.

···

On Wed, Jul 24, 2002 at 12:46:37AM +0900, Mike Hall wrote:


Mike Hall

Drop http://bike-nomad.com/vim/ruby.vim in your ~/.vim/ftplugin
directory. Voila. Better than sliced bread.

(Oh, make sure you drop http://mywebpage.netscape.com/bbenjif/vim/matchit.vim
into your ~/.vim/plugin directory, too.)

– Dossy

···

On 2002.07.18, Brad Cox bcox@virtualschool.edu wrote:

While we’re picking syntactic nits, how about replacing begin…end with
{…} throughout? I rely on vim parentheses matching heavily and
begin–end removes this indispensible cruth.


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)

I should be thanking you, matz. You’ve done a wonderful job with
Ruby. If there’s any way I can help out, let me know.

···

At 2:11 PM +0900 7/18/02, Yukihiro Matsumoto wrote:

That’s the way languages are designed. You smart people are helping
me now. Brad, I bought your book. It is my greatest astonishment for
years that I found you here. Thanks.


Brad Cox, PhD; bcox@virtualschool.edu 703 361 4751
o For industrial age goods there were checks and credit cards.
For everything else there is http://virtualschool.edu/mybank
o Interactive Learning Environment http://virtualschool.edu/ile
o Java Web Application Architecture: http://virtualschool.edu/jwaa

Hi –

···

On Wed, 24 Jul 2002, Jim Menard wrote:

Paul Brannan pbrannan@atdesk.com writes:

On Wed, Jul 24, 2002 at 12:46:37AM +0900, Mike Hall wrote:

  • compile time string concatenation, “hello” “world” => “helloworld”

I know that some other popular languages like to do that,
but I think it would be better to leave it as two arguments.
After all, someone wrote those two literals separately on purpose.

The following is a common idiom:

foo("this is a really long string. in fact, it is so long "
“that I have to wrap onto multiple lines.”)

or

foo("this is short\

and so is this")

The string would include the newline.

I don’t think that’s the case in either of these examples – only if
you do:

foo(“this is
a string”)

David


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

Hi –

Kyle Rawlins wrote:

  obj.method a, b, c {|i| xyz}

vs
obj.method a b c {|i| xyz}

Wouldn’t this add a significant amount of ambiguity and confusion? what if a
is a function that takes two arguments? what if the second is optional?

Don’t we have the same problem now, with commas?
We “solve” it with parens to group the arguments
and to clearly specify who goes with what.

I don’t think it’s the same problem. If you’ve got:

obj.method a, b, c {|i| xyz}

and (say) b is a method call that takes one optional argument, there’s
no danger that c will be interpreted as that argument.

I suspect that a Ruby-like language without commas separating method
arguments would end up with an awful lot of parentheses instead. (We
do have/use them now, as you point out, but they’d also have to do
what commas now do.)

David

···

On Thu, 25 Jul 2002, Mike Hall wrote:

On Wed, Jul 24, 2002 at 12:46:37AM +0900, Mike Hall wrote:


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

Actually, that version is quite old. Just use the one that comes stock
with your Vim 6.1.

Copy it from the $VIMRUNTIME/macros directory into your
$VIMRUNTIME/plugin directory.

···

On Wednesday 17 July 2002 05:25 pm, Dossy wrote:

On 2002.07.18, Brad Cox bcox@virtualschool.edu wrote:

While we’re picking syntactic nits, how about replacing
begin…end with {…} throughout? I rely on vim parentheses
matching heavily and begin–end removes this indispensible cruth.

Drop http://bike-nomad.com/vim/ruby.vim in your ~/.vim/ftplugin
directory. Voila. Better than sliced bread.

(Oh, make sure you drop
http://mywebpage.netscape.com/bbenjif/vim/matchit.vim into your
~/.vim/plugin directory, too.)


Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE

Thanks! Does anyone know of a linux 7.0 binary vim with ruby compiled
in? Tried to make one myself but got compile errors.

···

At 9:25 AM +0900 7/18/02, Dossy wrote:

On 2002.07.18, Brad Cox bcox@virtualschool.edu wrote:

While we’re picking syntactic nits, how about replacing begin…end with
{…} throughout? I rely on vim parentheses matching heavily and
begin–end removes this indispensible cruth.

Drop http://bike-nomad.com/vim/ruby.vim in your ~/.vim/ftplugin
directory. Voila. Better than sliced bread.

(Oh, make sure you drop http://mywebpage.netscape.com/bbenjif/vim/matchit.vim
into your ~/.vim/plugin directory, too.)


Brad Cox, PhD; bcox@virtualschool.edu 703 361 4751
o For industrial age goods there were checks and credit cards.
For everything else there is http://virtualschool.edu/mybank
o Interactive Learning Environment http://virtualschool.edu/ile
o Java Web Application Architecture: http://virtualschool.edu/jwaa

Good point.

Actually, since I’m using Debian woody, I just did this:

$ cp /usr/share/doc/vim/macros/matchit.* ~/.vim/plugin

$VIMRUNTIME points at /usr/share/vim/vim61 …

– Dossy

···

On 2002.07.18, Ned Konz ned@bike-nomad.com wrote:

(Oh, make sure you drop
http://mywebpage.netscape.com/bbenjif/vim/matchit.vim into your
~/.vim/plugin directory, too.)

Actually, that version is quite old. Just use the one that comes stock
with your Vim 6.1.

Copy it from the $VIMRUNTIME/macros directory into your
$VIMRUNTIME/plugin directory.


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)