Ruby wishlist

You can do this:

n1, n2, n3, n4 = nil

But you can't do this:

n1, n2, n3, n4 = [something]

And you can't do this:

n1, n2, n3, n4 [+,-,*, etc]= [something]

I really wish you could. I would make some of my
code so much more simple and concise.

Make the software work more for the user, and not the other
way around.

But you can't do this:

n1, n2, n3, n4 = [something]

Just add one simbol and you can:

$ irb --simple-prompt

n1, n2, n3, n4 = *[1, 2, 3, 4]

=> [1, 2, 3, 4]

n1

=> 1

n2

=> 2

n3

=> 3

n4

=> 4

And you can't do this:

n1, n2, n3, n4 [+,-,*, etc]= [something]

Not sure what you want here.

<...> Make the software work more for the user, and not the other

way around.

Make sure you know the software.

Regards,
Rimantas

···

--
http://rimantas.com/

n1, n2, n3, n4 = nil

This is a trivial thing to do because the semantics can't really be
anything else but the obvious: all variables are set to "nil".

But you can't do this:
n1, n2, n3, n4 = [something]

The semantics here aren't so clear. They seem clear if you say:

n1, n2, n3, n4 = 5

It seems to be saying "set all these variables to 5". But what about
this?:

n1, n2, n3, n4 = [1, 2, 3, 4]

What should the variables be set to? Should n1 be 1 or [1,2,3,4]?
Should n2 be 2 or [1,2,3,4]? Well maybe the answer is "clear" in that
it should do what the system already does: n1=1, n2=2, etc. You can
even then concoct a rule to explain this. "If the variable is a scalar
type, copy it to all recipients on the LHS. If it is an array type,
copy the array element by element as per the existing semantics."

But then how would I set four variables to the same array? Problem, eh?
I'd have to do something like this:

n1 = n2 = n3 = n4 = [1, 2, 3, 4]

But if I have to do that for one case and not any others, why not go for
maximal consistency and do that for all cases? You know, like we
currently do:

n1 = n2 = n3 = n4 = 5

So really the problem isn't that you can't do multiple assignment the
way you want, the problem is that nil is treated specially for no good
reason given that you can just as easily do:

n1 = n2 = n3 = n4 = nil.

Now myself? I'd go on the side of reducing semantic complexity rather
than increasing it. If anything I'd get rid of the behaviour n1, n2,
n3, n4 = nil instead of expanding on it in a nightmarish increase of
special cases. I mean really, it doesn't take that much extra typing
(four spaces) to do the version with equal signs.

And you can't do this:
n1, n2, n3, n4 [+,-,*, etc]= [something]

a,b,c,d = [1,2,3,4]
a,b,c,d = [a,b,c,d].collect { |x| x + 5 }

It's a bit ugly, but again not that much extra typing and certainly
still readable to anybody who knows even the basics of Ruby. It would
be uglier, again, to work out the semantics for the special cases you
seem to want to throw in. What happens if "something" is a scalar type?
An array type? A hash type? A user-defined type of some kind? A
string? A ... How many special cases do you want in the semantics?
Ruby already has way too many such for my tastes.

Don't get me wrong. I like syntactic (and semantic) sugar -- but not to
the point that it rots my mental teeth.

···

On Sun, 2008-06-08 at 12:18 +0900, jzakiya wrote:

--
Michael T. Richter <ttmrichter@gmail.com> (GoogleTalk:
ttmrichter@gmail.com)
Never, ever, ever let systems-level engineers do human interaction
design unless they have displayed a proven secondary talent in that
area. Their opinion of what represents good human-computer interaction
tends to be a bit off-track. (Bruce Tognazzini)

This really suggests that n1, n2, n3, n4 want to be n[1..4]. Then see
http://weblog.raganwald.com/2007/10/stringtoproc.html

martin

···

On Sat, Jun 7, 2008 at 8:18 PM, jzakiya <jzakiya@mail.com> wrote:

You can do this:

n1, n2, n3, n4 = nil

But you can't do this:

n1, n2, n3, n4 = [something]

And you can't do this:

n1, n2, n3, n4 [+,-,*, etc]= [something]

Sorry for the confusion.

I want to set multiple variable to the same value:

n1, n2, n3, n4 = 5

and do +=, -=, *=, etc with the same value

n1, n2, n3, n4 += 5

instead of

n1 += 9; n2 += 9; n3 += 9; n4 += 9

It would soooo much more expressive, and concise.

···

On Jun 7, 11:35 pm, Rimantas Liubertas <riman...@gmail.com> wrote:

> But you can't do this:

> n1, n2, n3, n4 = [something]

Just add one simbol and you can:

$ irb --simple-prompt>> n1, n2, n3, n4 = *[1, 2, 3, 4]
=> [1, 2, 3, 4]
>> n1
=> 1
>> n2
=> 2
>> n3
=> 3
>> n4

=> 4

> And you can't do this:

> n1, n2, n3, n4 [+,-,*, etc]= [something]

Not sure what you want here.

<...> Make the software work more for the user, and not the other

> way around.

Make sure you know the software.

Regards,
Rimantas
--http://rimantas.com/

> $ irb --simple-prompt>> n1, n2, n3, n4 = *[1, 2, 3, 4]

Probably easier to simply do

n1, n2, n3, n4 = 1, 2, 3, 4

But I'm not sure that's what you wanted.

n1, n2, n3, n4 = 5

n1 = n2 = n3 = n4 = 5

This works because the result of the assignment is the value which was
assigned. It's also not Ruby-specific. Probably even works in C.

and do +=, -=, *=, etc with the same value

n1, n2, n3, n4 += 5

This doesn't work because of the semantics of multiple assignment. See, your
first example:

n1, n2, n3, n4 = nil

That doesn't work because there's anything magical about nil. It works because
nil is the value when nothing is provided. It parses out to something like
this:

n1, n2, n3, n4 = nil, nil, nil, nil

And you can see this effect, too:

n1, n2, n3, n4 = 5

n1 will be 5, but n2, n3, and n4 won't be.

Now, with your semantics of doing a += there, shouldn't it be more like:

n1, n2, n3, n4 += 1, 2, 3, 4

instead of

n1 += 9; n2 += 9; n3 += 9; n4 += 9

Erm... I can't ever remember needing this. Not ever.

If you're trying to do it on an array, maybe something like:

0.upto(a.length-1) { |i| a[i] += 9 }

But unless I'm missing something -- and feel free to correct me with a real
example -- what you're trying to do really suggests that you want to refactor
your program a bit.

···

On Saturday 07 June 2008 23:03:47 jzakiya wrote:

On Jun 7, 11:35 pm, Rimantas Liubertas <riman...@gmail.com> wrote:

But you can't do this:
n1, n2, n3, n4 = [something]

Just add one simbol and you can:

$ irb --simple-prompt>> n1, n2, n3, n4 = *[1, 2, 3, 4]
=> [1, 2, 3, 4]

n1

=> 1

n2

=> 2

n3

=> 3

n4

=> 4

And you can't do this:
n1, n2, n3, n4 [+,-,*, etc]= [something]

Not sure what you want here.

<...> Make the software work more for the user, and not the other

way around.

Make sure you know the software.

!

Sorry for the confusion.

I want to set multiple variable to the same value:

n1, n2, n3, n4 = 5

Your variable naming indicates that you are probably using the wrong tool: you rather want an Array of values vs. a number of variables. If you do that, life becomes much easier:

and do +=, -=, *=, etc with the same value

n1, n2, n3, n4 += 5

ns.map! {|n| n + 5}

Kind regards

  robert

···

On 08.06.2008 06:00, jzakiya wrote:

On Jun 7, 11:35 pm, Rimantas Liubertas <riman...@gmail.com> wrote:

Hi --

···

On Sun, 8 Jun 2008, David Masover wrote:

If you're trying to do it on an array, maybe something like:

0.upto(a.length-1) { |i| a[i] += 9 }

You could also use each_index there:

   a.each_index {|i| a[i] += 9 }

or even:

   a.map! {|e| e + 9 }

David

--
Rails training from David A. Black and Ruby Power and Light:
   INTRO TO RAILS June 9-12 Berlin
   ADVANCING WITH RAILS June 16-19 Berlin
   ADVANCING WITH RAILS July 21-24 Edison, NJ
See http://www.rubypal.com for details and updates!

The names of the variables are not array values, they
are just different variable names, they could be any
names.

Remember, I would LIKE ruby to be able to do this.
It is my "whishlist". I know Ruby doesn't do it now,
but I would like it to be able to in the future. OK! :slight_smile:

Peace

Jabari

···

On Jun 8, 5:05 am, Robert Klemme <shortcut...@googlemail.com> wrote:

On 08.06.2008 06:00, jzakiya wrote:

> On Jun 7, 11:35 pm, Rimantas Liubertas <riman...@gmail.com> wrote:
>>> But you can't do this:
>>> n1, n2, n3, n4 = [something]
>> Just add one simbol and you can:

>> $ irb --simple-prompt>> n1, n2, n3, n4 = *[1, 2, 3, 4]
>> => [1, 2, 3, 4]
>>>> n1
>> => 1
>>>> n2
>> => 2
>>>> n3
>> => 3
>>>> n4
>> => 4

>>> And you can't do this:
>>> n1, n2, n3, n4 [+,-,*, etc]= [something]
>> Not sure what you want here.

>> <...> Make the software work more for the user, and not the other

>>> way around.
>> Make sure you know the software.

!

> Sorry for the confusion.

> I want to set multiple variable to the same value:

> n1, n2, n3, n4 = 5

Your variable naming indicates that you are probably using the wrong
tool: you rather want an Array of values vs. a number of variables. If
you do that, life becomes much easier:

> and do +=, -=, *=, etc with the same value

> n1, n2, n3, n4 += 5

ns.map! {|n| n + 5}

Kind regards

        robert

I think someone already asked this, but I want to confirm:

    I am trying to write a program with a GUI, but I don't know what GUI framework is the best.

    I have heard that JRuby is a good option, but also heard that Swing was a bad idea to use with JRuby.

    I want to be able to write this program so that the end user can install ruby, then run the program and it will start with no other installation needed (like installing gems, etc, however I can do the gems in the program on first run if it comes down to it).

    I hope that makes sense, any ideas?

        Sincerely,

            Jayce Meade

Yes, we understand that. It's just probably better design for your program as
a whole to use an array here.

Can you give us more detail as to why you want this feature?

···

On Sunday 08 June 2008 09:58:41 jzakiya wrote:

The names of the variables are not array values, they
are just different variable names, they could be any
names.

> I want to set multiple variable to the same value:

> n1, n2, n3, n4 = 5

Your variable naming indicates that you are probably using the wrong
tool: you rather want an Array of values vs. a number of variables. If
you do that, life becomes much easier:

> and do +=, -=, *=, etc with the same value

> n1, n2, n3, n4 += 5

ns.map! {|n| n + 5}

The names of the variables are not array values, they
are just different variable names, they could be any
names.

The names are irrelevant: the mere fact that you want to treat them
uniformly indicates that it is a bad idea to have them as separate
local variables and not in some type of collection.

Remember, I would LIKE ruby to be able to do this.
It is my "whishlist". I know Ruby doesn't do it now,
but I would like it to be able to in the future. OK! :slight_smile:

The question is whether it is *reasonable* to build this into the
language. It does not make sense to put something into the language
to support a) an esoteric case or b) sub optimal design.

Kind regards

robert

···

2008/6/8 jzakiya <jzakiya@mail.com>:

On Jun 8, 5:05 am, Robert Klemme <shortcut...@googlemail.com> wrote:

On 08.06.2008 06:00, jzakiya wrote:

--
use.inject do |as, often| as.you_can - without end

I think someone already asked this, but I want to confirm:

In the future, try to find the old thread and reply to it instead of starting
a new one.

    I am trying to write a program with a GUI, but I don't know what GUI
framework is the best.

Nobody knows that yet, I think. That's why there's so many of them.

    I want to be able to write this program so that the end user can install
ruby, then run the program and it will start with no other installation
needed (like installing gems, etc, however I can do the gems in the program
on first run if it comes down to it).

That's a completely separate problem from what GUI library to use. If you're
afraid to use libraries for this reason, SOLVE THIS PROBLEM NOW, and then
worry about GUI libraries. Simplifying your installation program is not an
excuse for NIH syndrome -- and just think how much time you'll have to polish
it if you find that half the program you wanted is already a gem.

If it's an open source project, or at least free-as-in-beer, you might
consider simply making it a gem. Then, all your users need to do is type:

gem install my_great_program

and all the dependent gems will be installed.

···

On Sunday 08 June 2008 02:03:23 ProgramDragon wrote:

ProgramDragon wrote:

I think someone already asked this, but I want to confirm:

   I am trying to write a program with a GUI, but I don't know what GUI framework is the best.

   I have heard that JRuby is a good option, but also heard that Swing was a bad idea to use with JRuby.

Not at all, Swing is a great idea. In fact, I'd go so far as to say Swing is a lot better idea from JRuby than from Java.

   I want to be able to write this program so that the end user can install ruby, then run the program and it will start with no other installation needed (like installing gems, etc, however I can do the gems in the program on first run if it comes down to it).

Monkeybars + Rawr can package up an application with all requirements into a single executable .jar, .app, or .exe...awesome stuff.

- Charlie

David,

        Sorry, lol.

        I am not afraid to use libraries, it's just that this is a bot program for deviantART's chat network, and usually the people that want to get them are not really that coherent in how to actually get one, so I'm trying to make it as simple as I can. It's just a few ruby source files that can be run with a batch file on Windows. It is open source, GNU GPL license. The user just has to download and extract the program from a zip file, however would that work with the Gems? It doesn't use a command prompt window, the main file is a .rbw file.

    One bot is installed by installing ruby, and then downloading, extracting it, and then installing a gem for colors, and then running it with a batch file. I would prefer to keep it simple as installing ruby, download, extract, and run. I don't mind using gems or having to install them, but the user that gets the program might.

···

--------------------------------------------------
From: "David Masover" <ninja@slaphack.com>
Sent: Sunday, June 08, 2008 12:23 AM
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Subject: Re: GUI library/framework?

On Sunday 08 June 2008 02:03:23 ProgramDragon wrote:

I think someone already asked this, but I want to confirm:

In the future, try to find the old thread and reply to it instead of starting
a new one.

    I am trying to write a program with a GUI, but I don't know what GUI
framework is the best.

Nobody knows that yet, I think. That's why there's so many of them.

    I want to be able to write this program so that the end user can install
ruby, then run the program and it will start with no other installation
needed (like installing gems, etc, however I can do the gems in the program
on first run if it comes down to it).

That's a completely separate problem from what GUI library to use. If you're
afraid to use libraries for this reason, SOLVE THIS PROBLEM NOW, and then
worry about GUI libraries. Simplifying your installation program is not an
excuse for NIH syndrome -- and just think how much time you'll have to polish
it if you find that half the program you wanted is already a gem.

If it's an open source project, or at least free-as-in-beer, you might
consider simply making it a gem. Then, all your users need to do is type:

gem install my_great_program

and all the dependent gems will be installed.

Is that so? Sounds cool. So I would be able to package my entire program into a jar, .app or executable? I'm still not quite sure how to get it to load things from outside the executable though, because the program isn't installed into C:\Program Files. Most often it's extracted into a folder on the user's desktop, so it needs to be able to generate a filepath. I have been using Dir.getwd to generate a filepath to my main file, and then an argument passed to the filepath method adds folder names onto the end, lol. Would that still work, do you think? Here is my basic structure for the program's directory, say it's in a folder called Ecko (doh). It would look like this, if you outlined it.

/Ecko
    Main.rbw
    /System
        config.rb
        /Core
            connection.class.rb
            parse.class.rb
            users.class.rb
            extensions.class.rb
        /Extensions
        /Logs
        /Images
            /Screenshots
            /Splash
        /Data
        /Docs
            index.html

Basic layout, but that's what it would have to be able to go into if it was an executable. Lol, I must sound like an idiot. xP

···

--------------------------------------------------
From: "Charles Oliver Nutter" <charles.nutter@sun.com>
Sent: Sunday, June 08, 2008 10:07 AM
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Subject: Re: GUI library/framework?

ProgramDragon wrote:

I think someone already asked this, but I want to confirm:

   I am trying to write a program with a GUI, but I don't know what GUI framework is the best.

   I have heard that JRuby is a good option, but also heard that Swing was a bad idea to use with JRuby.

Not at all, Swing is a great idea. In fact, I'd go so far as to say Swing is a lot better idea from JRuby than from Java.

   I want to be able to write this program so that the end user can install ruby, then run the program and it will start with no other installation needed (like installing gems, etc, however I can do the gems in the program on first run if it comes down to it).

Monkeybars + Rawr can package up an application with all requirements into a single executable .jar, .app, or .exe...awesome stuff.

- Charlie

Look up rubyscript2exe. It packages your program, all its libraries
and the ruby interpreter itself into a single executable.

martin

···

On Sun, Jun 8, 2008 at 12:38 AM, ProgramDragon <programdragon@live.com> wrote:

      I am not afraid to use libraries, it's just that this is a bot program
for deviantART's chat network, and usually the people that want to get them
are not really that coherent in how to actually get one, so I'm trying to
make it as simple as I can. It's just a few ruby source files that can be

AzimuthDragon wrote:

Is that so? Sounds cool. So I would be able to package my entire program into a jar, .app or executable? I'm still not quite sure how to get it to load things from outside the executable though, because the program isn't installed into C:\Program Files. Most often it's extracted into a folder on the user's desktop, so it needs to be able to generate a filepath. I have been using Dir.getwd to generate a filepath to my main file, and then an argument passed to the filepath method adds folder names onto the end, lol. Would that still work, do you think? Here is my basic structure for the program's directory, say it's in a folder called Ecko (doh). It would look like this, if you outlined it.

Yeah, that's the goal behind David Koontz's stuff in Monkeybars and Rawr. I'm pretty sure you can provide your own structure, but he'd probably know better. David, you out there?

Alternatively, try #monkeybars on freenode during the week.

- Charlie

Martin,

    Thanks, I had forgotten about that. Can it also load files from other folders such as a Plugins folder? This program is supposed to be able to have extensions added once it's completed. I am fairly new to Ruby, I've only been working with it a few months. Sorry if I am asking stupid questions, just trying to get advice from experts. =P

···

--------------------------------------------------
From: "Martin DeMello" <martindemello@gmail.com>
Sent: Sunday, June 08, 2008 12:45 AM
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Subject: Re: GUI library/framework?

On Sun, Jun 8, 2008 at 12:38 AM, ProgramDragon <programdragon@live.com> > wrote:

      I am not afraid to use libraries, it's just that this is a bot program
for deviantART's chat network, and usually the people that want to get them
are not really that coherent in how to actually get one, so I'm trying to
make it as simple as I can. It's just a few ruby source files that can be

Look up rubyscript2exe. It packages your program, all its libraries
and the ruby interpreter itself into a single executable.

martin

Okay, I will give that a whirl Tuesday. SCHOOLS OUT! WOOT

···

--------------------------------------------------
From: "Charles Oliver Nutter" <charles.nutter@sun.com>
Sent: Sunday, June 08, 2008 3:08 PM
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Subject: Re: GUI library/framework?

AzimuthDragon wrote:

Is that so? Sounds cool. So I would be able to package my entire program into a jar, .app or executable? I'm still not quite sure how to get it to load things from outside the executable though, because the program isn't installed into C:\Program Files. Most often it's extracted into a folder on the user's desktop, so it needs to be able to generate a filepath. I have been using Dir.getwd to generate a filepath to my main file, and then an argument passed to the filepath method adds folder names onto the end, lol. Would that still work, do you think? Here is my basic structure for the program's directory, say it's in a folder called Ecko (doh). It would look like this, if you outlined it.

Yeah, that's the goal behind David Koontz's stuff in Monkeybars and Rawr. I'm pretty sure you can provide your own structure, but he'd probably know better. David, you out there?

Alternatively, try #monkeybars on freenode during the week.

- Charlie