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

I’m not digging it.

said on

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

Yeah, doesn’t fit right in my brain.

said on

Ugly. Unnecessary.

said on

I don’t like it either

said on

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

said on

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

said on

I’m not really keen on it either.

said on

end = readable, parseable

;; = just parseable

said on

Feels too much like shell programming, to me.

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

I don’t think so, personally.

said on

Deer footprints dashing away.

said on

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

said on

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

said on

Death to the semicolons of Gemini!

said on

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

said on

Good gravy, it’s hideous

Like Austin, I’m having sh flashbacks.

said on

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

said on
 
 def fugly
  # Cripes! At least use :) or
  # something cute
 ;;
 
said on

Oooh, even better:

def bash_like
  if you_like_it?
    you_are_nuts!
  fi
fed
said on

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

said on

i hate it!

said on

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

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

said on

Snow cannot last—Spring!

Novel syntax fails to please;

Deer hoofprints erode.

said on

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

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

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

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

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

said on
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
said on

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
class Foo < Bar
  def foo(x)
    p x
  -;
-;

Lisp style.  easy to count -; than ;;

class Foo < Bar
  def foo(x) p x -;-;
said on

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

Comments are closed for this entry.