hoodwink.d enhanced
RSS
2.0
XHTML
1.0

RedHanded

Block Terminator #

by babie in bits

This entry is loose translation of matz blog 2005-06-07 .

Matz added new block terminator to 1.9 branch. He thinks highly of “end”, ordinary block terminator, for reasons given below:
  • Because “end” means an end of a block obviously, a block can be an expression. This point is superior to Python whose block is nothing but statement.
  • Of course, you can do the same thing by using “{ ... }”, but “end” is more beautiful than that in case that a block has multiple paragraphs such as “case … when …” and “begin … rescue …”.

But He cares about that “end”’s visual inpact is a bit too far.

He was inspired by a new programing language Qu , then he add new block terminator ”;;”.

I tried it:
$ ./ruby1.9 -ve '
class Foo
  def self.foo(x)
    p x
  ;;
;;
Foo.foo "Hello, Qu!" 
'
ruby 1.9.0 (2005-06-28) [i686-linux]
"Hello, Qu!" 
Wow! How wonderful! But He warned:
Don’t use this feature seriously. I may delete it without prior notice. —Oops, I should have done this on April Fool.
said on 28 Jun 2005 at 05:40

I’m not digging it.

said on 28 Jun 2005 at 05:49

To me, it looks ugly and seems like a waste. It wouldn’t hurt to have more diversity though, I guess. To a point.

said on 28 Jun 2005 at 05:49

Yeah, doesn’t fit right in my brain.

said on 28 Jun 2005 at 06:00

Ugly. Unnecessary.

said on 28 Jun 2005 at 06:35

I don’t like it either

said on 28 Jun 2005 at 06:51

Y’know – compared to ‘end’ ‘end’ ‘end’ it ain’t too bad. You guys have a better suggestion?

said on 28 Jun 2005 at 07:09

I actually prefer ‘end’ ‘end’ ‘end’. :-/

said on 28 Jun 2005 at 07:50

I’m not really keen on it either.

said on 28 Jun 2005 at 07:55

end = readable, parseable

;; = just parseable

said on 28 Jun 2005 at 08:18

Feels too much like shell programming, to me.

case ${foo}
  foo) echo Foo!
       ;;
esac

I don’t think so, personally.

said on 28 Jun 2005 at 08:37

Deer footprints dashing away.

said on 28 Jun 2005 at 09:16

And if we’re lucky, they’ll never dash back!

said on 28 Jun 2005 at 09:20

“end” always remdinded me of Pascal. I’ll be a lone dissenter and say I like it.

said on 28 Jun 2005 at 09:32

Death to the semicolons of Gemini!

said on 28 Jun 2005 at 10:14

Those aren’t deer footprints, they are tears of pain streaming from my eyes.

said on 28 Jun 2005 at 10:41

Good gravy, it’s hideous

Like Austin, I’m having sh flashbacks.

said on 28 Jun 2005 at 10:52

I should said ‘funny’ instead of ‘wonderful’...

said on 28 Jun 2005 at 10:54
 
 def fugly
  # Cripes! At least use :) or
  # something cute
 ;;
 
said on 28 Jun 2005 at 11:54

Oooh, even better:

def bash_like
  if you_like_it?
    you_are_nuts!
  fi
fed
said on 28 Jun 2005 at 12:29

From an aesthetic point of view it lacks the symmetry of do...end and {...} :\

said on 28 Jun 2005 at 12:43

i hate it!

said on 28 Jun 2005 at 12:49

Someone posted this to #ruby-lang (my apologies, I forget who it was), and I was struck by the simplicity and elegance of the solution…I wonder where I’ve seen it before…

By using an sexp-like syntax you waste so much less space and it’s not nearly as ugly as curly-braces. The downward staircase of end-s has always irked me, it feels unnecessary and is quite possibly the only wart on an otherwise beautiful language (IMHO).

said on 28 Jun 2005 at 14:00

Slyphon: Oh, neat. I shall have to start doing that. Drive my co-conspirators crazy.

said on 28 Jun 2005 at 14:17

Snow cannot last—Spring!

Novel syntax fails to please;

Deer hoofprints erode.

said on 28 Jun 2005 at 16:05

I don’t like it either. I might tend to agree with “language diversity”, but having to read that in someone else’s code would annoy me.

said on 28 Jun 2005 at 16:35

I am going to say that it is not all that bad. It must be our natural archetypes or something… bash == evil?

It would be nice to have a third option for when things don’t seem to look right (arguable, though, that it would never look right with these). I say we leave it in at least for one month to see if it will grow on some. If at that point there does not seem to be a good following then rip it out and throw it to the raging crowd who will then systematically rip it to shreds never to be seen again.

said on 28 Jun 2005 at 17:29

ok, I’ll tell you: I want \n to act as a terminator for methods on one line, so that def foo(x) print x

is equal to

def foo(x) print x end

this would avoid end;end;end; sindrome and also implicitly suggest short methods :)

said on 28 Jun 2005 at 19:46

I like the step-down staircase of end end end, I align em all up with their opening statements and I visually match em.

said on 29 Jun 2005 at 00:47

I dont like it much, but different (good) ways to do the same thing are usually ..useful. So i hope this stays…

said on 29 Jun 2005 at 02:52
class Foo
   def self.foo(x)
      p x
   ;;
;;

Foo.foo "Hello, Qu!"

vs.

(class Foo
   (def self.foo(x) p x))

Foo.foo "Hello, Qu!"

I can really dig that sexp-esque syntax.

said on 29 Jun 2005 at 07:48
said on 04 Jul 2005 at 20:26

Of course sexp is the Omega point for all programming language. Just wait, you’ll see.

Personally I’ve hacked my Ruby interperter to recognize non-breaking space (0xA0) as the end-of-block terminator. Now girls always talk to me at parties (but I can’t tell when they’ve finished talking. Hmm.)

said on 08 Jul 2005 at 00:23
class Foo < Bar
  def foo(x)
    p x
  -;
-;

Lisp style.  easy to count -; than ;;

class Foo < Bar
  def foo(x) p x -;-;
said on 19 Aug 2005 at 19:29

-; looks like tiny upside-down claw hammers. Like I might be prying up bad code :)

Comments are closed for this entry.