Some comments on new 1.9 features

an people who don't like to move their fingers off of the

   a s d f j k l ;

:wink:

-a

···

On Fri, 4 Nov 2005, ts wrote:

> 3) Going to confuse all the people coming from Lisp...

perhaps the persons coming from Caml will be happy ...

--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
anything that contradicts experience and logic should be abandoned.
-- h.h. the 14th dalai lama

===============================================================================

Quoting ts <decoux@moulon.inra.fr>:

> 3) Going to confuse all the people coming from Lisp...

perhaps the persons coming from Caml will be happy ...

Or confused, because it is similar but different to what it means in
Caml.

-mental

mental@rydia.net wrote:

Quoting Domenico De Felice <defelicedomenico@gmail.com>:

> class Foo:
> def foo: "foo"
>
> It sounds more expressive than do .. ;;

Serious question: why not permit multi-line bodies this way, by
lining up indention?

Not like Python, but more like Haskell, where using "layout" is
merely optional.

That's interesting. It's quite clean. Which is better because....

I fear the Perly coming-on.

T.

James Edward Gray II wrote:

class Foo
   def foo; "foo" ;;
end

To save one character?

class Foo
  def foo; "foo" end
end

Hey! I didn’t say that it was great. I just showed what I thought was
the rationale behind having ;; in Ruby. Don't blame me for its
existance.

I didn't mean to blame anyone. I was just trying to understand. :slight_smile:

Anyway, it’s not about saving one character. It’s about
having the ; have a better counterpart than end in this particular
instance.

For a fitting counterpart, I like

class Foo
   def foo() "foo" end
end

James Edward Gray II

···

On Nov 4, 2005, at 1:19 PM, Nikolai Weibull wrote:

On Nov 4, 2005, at 10:53 AM, Nikolai Weibull wrote:

Sorry for the misunderstanding.

I like the "local" and "share" directives. That would make it clear.

Using too many special characters clutter the code and worsen
readability.

Austin Ziegler wrote:

It sounds too much like Python. Python's syntax is one of the reasons
I don't use Python.

Well, the idea was to give everyone the choice of what they wanted to
use, delimited blocks, or indentation blocks. The only issue with this
is that it adds complexity and one’d have to be able to stand reading
both ways of writing code. I read somewhere that the biggest problem
with C is that it doesn’t restrict the syntax enough:

        if (<test>)
                <statement a>
                <statement b>

It’s an accident waiting to happen. And while having an expressive
syntax is sweet and all, it can cause problems that are hard to spot.
I’m certainly not in the “There’s Only One Way To Write It” camp, but
there is some merit to having a simple, unambiguous syntax.

        nikolai

···

--
Nikolai Weibull: now available free of charge at http://bitwi.se/\!
Born in Chicago, IL USA; currently residing in Gothenburg, Sweden.
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}

Austin Ziegler wrote:
[CUT]

> class Foo:
> def foo: "foo"
>
> It sounds more expressive than do .. ;;

..

It sounds too much like Python. Python's syntax is one of the reasons
I don't use Python.

I didn't mean a indentation-block as in Python, but just to use a colon
with one-statement blocks. Multi-statements blocks would look the same.

class Foo
   def foo
      a = "foo"
      a
   end
   def bar: "bar"
end

The indentation of the statement following the colon would be ignored.
It looks prettier than the double semicolon to me.
With multilines blocks I can't see any reason to change the do .. end
syntax.

···

On 11/4/05, Domenico De Felice <defelicedomenico@gmail.com> wrote:

--
Domenico

No! I like to standardize badly indented code of other people using my
editors autoindent function. And I also rely on autoindenting while
writing code. So no significant indentation, please.

brian

···

On 04/11/05, mental@rydia.net <mental@rydia.net> wrote:

Quoting Domenico De Felice <defelicedomenico@gmail.com>:

> class Foo:
> def foo: "foo"
>
> It sounds more expressive than do .. ;;

Serious question: why not permit multi-line bodies this way, by
lining up indention?

Not like Python, but more like Haskell, where using "layout" is
merely optional.

-mental

--
http://ruby.brian-schroeder.de/

Stringed instrument chords: http://chordlist.brian-schroeder.de/

Dale Martenson wrote:

Sorry for the misunderstanding.

I like the "local" and "share" directives. That would make it clear.

Using too many special characters clutter the code and worsen
readability.

Yes, something like

{ |a, b|
   local a
   share b
   a = 1
   b = 2
}

would look less weird. However it has the problem that in bigger blocks
the programmer would need to read back the top of the block when he
'forgets' which attributes are local and which shared.

Anyway both solutions seem quite good to me

···

--
Domenico

David A. Black ha scritto:

Do we all not like ";;"?

As a pointless no-op, it's great :slight_smile: Is it really being considered as
a synonym for 'end'? I don't understand that at all.

For what I understand: not it was a joke, mostly like GOTO in yarv (hey, that took me weeks to understand it :slight_smile:

Your keyboard is broken, end is on the center row:

` 1 2 3 4 5 6 7 8 9 0
    ' , . p y f g c r l / = \
     a o e u i d h t n s -
      ; q j k x b m w v z

···

On Nov 4, 2005, at 7:26 AM, Ara.T.Howard wrote:

On Fri, 4 Nov 2005, ts wrote:

> 3) Going to confuse all the people coming from Lisp...

perhaps the persons coming from Caml will be happy ...

an people who don't like to move their fingers off of the

  a s d f j k l ;

--
Eric Hodel - drbrain@segment7.net - http://segment7.net
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

Nikolai Weibull <mailing-lists.ruby-talk@rawuncut.elitemail.org> writes:

Austin Ziegler wrote:

It sounds too much like Python. Python's syntax is one of the reasons
I don't use Python.

Well, the idea was to give everyone the choice of what they wanted to
use, delimited blocks, or indentation blocks. The only issue with this
is that it adds complexity and one’d have to be able to stand reading
both ways of writing code. I read somewhere that the biggest problem
with C is that it doesn’t restrict the syntax enough:

        if (<test>)
                <statement a>
                <statement b>

Using editors that actually can parse what they indent helps a lot
with that. I wouldn't want to code longer pieces without one.

That said, I don't want indentation blocks in Ruby either.

···

nikolai

--
Christian Neukirchen <chneukirchen@gmail.com> http://chneukirchen.org

IMO, this is not a good idea. Choose one and stick with it. Also IMO,
Ruby came down on the right side of the debate -- indentation blocks
are excessively fragile.

-austin

···

On 11/4/05, Nikolai Weibull <mailing-lists.ruby-talk@rawuncut.elitemail.org> wrote:

Austin Ziegler wrote:
> It sounds too much like Python. Python's syntax is one of the reasons
> I don't use Python.
Well, the idea was to give everyone the choice of what they wanted to
use, delimited blocks, or indentation blocks.

--
Austin Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca

Ruby permits multiple statements on a single line. Your proposal:

  def bar: "bar"

looks unbalanced (because, in fact, it is). It gets worse if you do:

  def bar: foo; "bar"

Sorry, but I think that this -- and ;; -- are both bad ideas that
should be dropped.

-austin

···

On 11/5/05, Domenico De Felice <defelicedomenico@gmail.com> wrote:

Austin Ziegler wrote:
> It sounds too much like Python. Python's syntax is one of the reasons
> I don't use Python.
I didn't mean a indentation-block as in Python, but just to use a colon
with one-statement blocks. Multi-statements blocks would look the same.

class Foo
   def foo
      a = "foo"
      a
   end
   def bar: "bar"
end

The indentation of the statement following the colon would be ignored.
It looks prettier than the double semicolon to me.
With multilines blocks I can't see any reason to change the do .. end
syntax.

--
Austin Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca

Quoting Domenico De Felice <defelicedomenico@gmail.com>:

> Using too many special characters clutter the code and worsen
> readability.

Yes, something like

{ |a, b|
   local a
   share b
   a = 1
   b = 2
}

would look less weird. However it has the problem that in bigger
blocks the programmer would need to read back the top of the block
when he 'forgets' which attributes are local and which shared.

I don't know ... honestly, why can't we just make the block
parameters always block-local? Having to make closure explicit
with share doesn't strike me as very helpful.

There's also a certain "oh, by the way, that variable mentioned
earlier is actually closed over from the enclosing scope" factor.
Not great for comprehensibility.

-mental

Domenico De Felice wrote:

Dale Martenson wrote:
> Sorry for the misunderstanding.
>
> I like the "local" and "share" directives. That would make it clear.
>
> Using too many special characters clutter the code and worsen
> readability.

Yes, something like

{ |a, b|
   local a
   share b
   a = 1
   b = 2
}

would look less weird. However it has the problem that in bigger blocks
the programmer would need to read back the top of the block when he
'forgets' which attributes are local and which shared.

They would'nt *have* to be just at the top. You could even do it
conditionally, although usage is subtle:

  x = false

  a = 1
  b = 2
  lam1 = lambda { |a, b|
     a = 2
     b = 4
     if x
       share b
     end
  }
  lam2 = lambda { b + 1}

  lam1.call
  lam2.call #=> 3

  x = true

  lam1.call
  lam2.call #=> 5

Closure Magic, yes?

T.

*snip*

and one’d have to be able to stand reading both ways of writing code.

*snip*

And learn both. Yuck. That's the problem.

···

On Saturday 05 November 2005 07:45, Christian Neukirchen wrote:

Austin Ziegler wrote:

···

On 11/4/05, Nikolai Weibull > <mailing-lists.ruby-talk@rawuncut.elitemail.org> wrote:

> Austin Ziegler wrote:

> > It sounds too much like Python. Python's syntax is one of the
> > reasons I don't use Python.

> Well, the idea was to give everyone the choice of what they wanted
> to use, delimited blocks, or indentation blocks.

IMO, this is not a good idea. Choose one and stick with it. Also IMO,
Ruby came down on the right side of the debate -- indentation blocks
are excessively fragile.

Thanks for repeating what I said in the rest of my response, which you
have elided here.

        nikolai

--
Nikolai Weibull: now available free of charge at http://bitwi.se/\!
Born in Chicago, IL USA; currently residing in Gothenburg, Sweden.
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}

Trans wrote:
[CUT]

They would'nt *have* to be just at the top. You could even do it
conditionally, although usage is subtle:

[CUT]

  lam1 = lambda { |a, b|
     a = 2
     b = 4
     if x
       share b
     end
  }

[CUT]

Yeah.. share and local directives could be used like any other
command.. this usage is nice. It wouldn't be possible using the special
character (at least not without doing weird things). However variables
scoping, when statically defined, will still be less intuitive than
using special char.

···

--
Domenico

mental@rydia.net wrote:
[CUT]

I don't know ... honestly, why can't we just make the block
parameters always block-local? Having to make closure explicit
with share doesn't strike me as very helpful.

There's also a certain "oh, by the way, that variable mentioned
earlier is actually closed over from the enclosing scope" factor.
Not great for comprehensibility.

Indeed this feature is not essential at all.. but it could come handy
to make some tasks easier.
Anyway if the block will be used 'normally', no directive or something
strange would be used. This should hide anything confusing.

···

--
Domenico