Forum: Ruby-core [ruby-trunk - Feature #9070][Open] Introduce `---` as synonym of `end` keyword

C4e88907313843cf07f6d85ba8162120?d=identicon&s=25 alexeymuranov (Alexey Muranov) (Guest)
on 2013-11-01 15:18
(Received via mailing list)
Issue #9070 has been reported by alexeymuranov (Alexey Muranov).

----------------------------------------
Feature #9070: Introduce `---` as synonym of `end` keyword
https://bugs.ruby-lang.org/issues/9070

Author: alexeymuranov (Alexey Muranov)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:


=begin
This is just an idea: introduce "(({---}))" as synonym of "(({end}))"
keyword.

It is a bit easier to type and to read, and makes whitespace insensitive
language look as if it follows off-side rule.  Compare:

  class Person
    attr_reader :name, :age
    def initialize(name, age)
      @name, @age = name, age
    ---
    def <=>(person) # the comparison operator for sorting
      age <=> person.age
    ---
    def to_s
      "#{name} (#{age})"
    ---
  ---

  class Person
    attr_reader :name, :age
    def initialize(name, age)
      @name, @age = name, age
    end
    def <=>(person) # the comparison operator for sorting
      age <=> person.age
    end
    def to_s
      "#{name} (#{age})"
    end
  end

=end
0ec4920185b657a03edf01fff96b4e9b?d=identicon&s=25 matz (Yukihiro Matsumoto) (Guest)
on 2013-11-01 16:35
(Received via mailing list)
Issue #9070 has been updated by matz (Yukihiro Matsumoto).

Assignee set to matz (Yukihiro Matsumoto)

Hmm, interesting idea. But it looks bit ugly, isn't it?

FYI, I have once experimented ';;' as replacement of 'end' (I even
modified ruby-mode.el as well).
But it turned out to be confusing, and I gave up.

I am not sure your '---' idea will work.  Seems better than ';;' at
least.

Matz.
----------------------------------------
Feature #9070: Introduce `---` as synonym of `end` keyword
https://bugs.ruby-lang.org/issues/9070#change-42712

Author: alexeymuranov (Alexey Muranov)
Status: Open
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category:
Target version:


=begin
This is just an idea: introduce "(({---}))" as synonym of "(({end}))"
keyword.

It is a bit easier to type and to read, and makes whitespace insensitive
language look as if it follows off-side rule.  Compare:

  class Person
    attr_reader :name, :age
    def initialize(name, age)
      @name, @age = name, age
    ---
    def <=>(person) # the comparison operator for sorting
      age <=> person.age
    ---
    def to_s
      "#{name} (#{age})"
    ---
  ---

  class Person
    attr_reader :name, :age
    def initialize(name, age)
      @name, @age = name, age
    end
    def <=>(person) # the comparison operator for sorting
      age <=> person.age
    end
    def to_s
      "#{name} (#{age})"
    end
  end

=end
F1c4a3bb1606cc4a61711e61e2fe6146?d=identicon&s=25 sikachu (Prem Sichanugrist) (Guest)
on 2013-11-01 16:37
(Received via mailing list)
Issue #9070 has been updated by sikachu (Prem Sichanugrist).


It does look ugly. I don't think that really makes the code better.

Also, I think if you leave a space after each method, then `end` really
works fine here.
----------------------------------------
Feature #9070: Introduce `---` as synonym of `end` keyword
https://bugs.ruby-lang.org/issues/9070#change-42713

Author: alexeymuranov (Alexey Muranov)
Status: Open
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category:
Target version:


=begin
This is just an idea: introduce "(({---}))" as synonym of "(({end}))"
keyword.

It is a bit easier to type and to read, and makes whitespace insensitive
language look as if it follows off-side rule.  Compare:

  class Person
    attr_reader :name, :age
    def initialize(name, age)
      @name, @age = name, age
    ---
    def <=>(person) # the comparison operator for sorting
      age <=> person.age
    ---
    def to_s
      "#{name} (#{age})"
    ---
  ---

  class Person
    attr_reader :name, :age
    def initialize(name, age)
      @name, @age = name, age
    end
    def <=>(person) # the comparison operator for sorting
      age <=> person.age
    end
    def to_s
      "#{name} (#{age})"
    end
  end

=end
C4e88907313843cf07f6d85ba8162120?d=identicon&s=25 alexeymuranov (Alexey Muranov) (Guest)
on 2013-11-01 18:44
(Received via mailing list)
Issue #9070 has been updated by alexeymuranov (Alexey Muranov).


matz (Yukihiro Matsumoto) wrote:
> Hmm, interesting idea. But it looks bit ugly, isn't it?
>
> FYI, I have once experimented ';;' as replacement of 'end' (I even modified
ruby-mode.el as well).
> But it turned out to be confusing, and I gave up.
>
> I am not sure your '---' idea will work.  Seems better than ';;' at least.

So, maybe the Feedback status for now?  I imagine this is a matter of
personal taste, i proposed because i think i would have liked my code to
look like that.  This looks to me like the best approximation to the
indentation based syntax without being indentation based.


----------------------------------------
Feature #9070: Introduce `---` as synonym of `end` keyword
https://bugs.ruby-lang.org/issues/9070#change-42714

Author: alexeymuranov (Alexey Muranov)
Status: Open
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category:
Target version:


=begin
This is just an idea: introduce "(({---}))" as synonym of "(({end}))"
keyword.

It is a bit easier to type and to read, and makes whitespace insensitive
language look as if it follows off-side rule.  Compare:

  class Person
    attr_reader :name, :age
    def initialize(name, age)
      @name, @age = name, age
    ---
    def <=>(person) # the comparison operator for sorting
      age <=> person.age
    ---
    def to_s
      "#{name} (#{age})"
    ---
  ---

  class Person
    attr_reader :name, :age
    def initialize(name, age)
      @name, @age = name, age
    end
    def <=>(person) # the comparison operator for sorting
      age <=> person.age
    end
    def to_s
      "#{name} (#{age})"
    end
  end

=end
05ba106041716c821d3ab34bd60ea220?d=identicon&s=25 David MacMahon (Guest)
on 2013-11-01 19:02
(Received via mailing list)
On Nov 1, 2013, at 10:44 AM, alexeymuranov (Alexey Muranov) wrote:

> This looks to me like the best approximation to the indentation based syntax
without being indentation based.

One easy way to get that appearance right now would be to append ";end"
to the end of the preceding line:

 class Person
   attr_reader :name, :age
   def initialize(name, age)
     @name, @age = name, age ;end

   def <=>(person) # the comparison operator for sorting
     age <=> person.age; end

   def to_s
     "#{name} (#{age})" ;end ;end

Of course, when adding a new method at the end of class Person you need
to make sure to put it in between the two ";end" statements.

Disclaimer: I am not advocating this solution; I am just pointing out
that it could be done this way.  I personally like having outdented
"end" statements on separate lines, but this is obviously a subjective
preference.  Giving lexical significant to the amount of whitespace at
the beginning of line really bothers me and is one of the reasons I
prefer Ruby to Python! :-)

Dave
This topic is locked and can not be replied to.