D
Diego.Virasoro
Hi,
first of all let me say I really really like Ruby, and I look forward
to use it in my projects.
There are however a couple of questions I have and features I miss from
my other languages (mainly Fortran and C++... I am not a CS ^_^) and I
would like to know more if Ruby implements something similar, and if it
does not if there is any possibilities it may do so in the future
(after all Ruby seems to take the best feature from the various
languages).
Here it's a list of my current problems:
-Is there a way to have multidimentional arrays in Ruby? Ie something
like variable[3][2]? One could use arrays of arrays but it does not
look quite as clear when reading the code.
-Fortran 95 had a really nice feature when using arrays: you could
assign values using ranges. I am glad to see something similar exist in
Ruby too, (eg. variable[0..100]=0)
However F95 went a bit further, since the ranges could include an
optional parameter, the step. In F95 it would look something like:
variable[min:max:step] = 0
There's a lot of cases when something like this is really convinient. I
know you can produce a similar effect using a few more lines, but I
think a feature like a range+step would have several advantages, namely
that it would look more clear in less code (a common feature in Ruby)
and it's closer to the way we think to be very desirable. Has there
been any talk about such a feature in future Ruby?
-What is the difference between the << and + concatenation for strings?
Is it just that the former modifies the string while the second one
returns a new string? Why then not use something like +! (just as an
alternative)?
-I read the discussion about the use of the "end" keyword, and possible
alternatives. Instead of trying to change that, I think it would be
easier and more consistent with Ruby's syntax to change the way if,
unless and while work so that they take a block as an argument. Then
if/while would work more consistently as the other methods, and in
particular the iterators: in both cases you could delimit the code with
a keyword like "end" or the curly bracket. For example these would be
all acceptable:
if(x==y) do
#code
end
if(x==y) {
#code
}
(the first one would pretty much look like it already does, and one
could decide that "do" can be omitted to make it compatible with
existing code.)
In other words it would look just like for iterators (more consistent
Ruby) and at the same time make happy those that want brackets instead
of keywords to delimit if/while/unless: two birds with one stone.
Thank you very much. Anyway Ruby keeps being a great language and I
really love it (though I have not use it much yet).
Diego Virasoro
first of all let me say I really really like Ruby, and I look forward
to use it in my projects.
There are however a couple of questions I have and features I miss from
my other languages (mainly Fortran and C++... I am not a CS ^_^) and I
would like to know more if Ruby implements something similar, and if it
does not if there is any possibilities it may do so in the future
(after all Ruby seems to take the best feature from the various
languages).
Here it's a list of my current problems:
-Is there a way to have multidimentional arrays in Ruby? Ie something
like variable[3][2]? One could use arrays of arrays but it does not
look quite as clear when reading the code.
-Fortran 95 had a really nice feature when using arrays: you could
assign values using ranges. I am glad to see something similar exist in
Ruby too, (eg. variable[0..100]=0)
However F95 went a bit further, since the ranges could include an
optional parameter, the step. In F95 it would look something like:
variable[min:max:step] = 0
There's a lot of cases when something like this is really convinient. I
know you can produce a similar effect using a few more lines, but I
think a feature like a range+step would have several advantages, namely
that it would look more clear in less code (a common feature in Ruby)
and it's closer to the way we think to be very desirable. Has there
been any talk about such a feature in future Ruby?
-What is the difference between the << and + concatenation for strings?
Is it just that the former modifies the string while the second one
returns a new string? Why then not use something like +! (just as an
alternative)?
-I read the discussion about the use of the "end" keyword, and possible
alternatives. Instead of trying to change that, I think it would be
easier and more consistent with Ruby's syntax to change the way if,
unless and while work so that they take a block as an argument. Then
if/while would work more consistently as the other methods, and in
particular the iterators: in both cases you could delimit the code with
a keyword like "end" or the curly bracket. For example these would be
all acceptable:
if(x==y) do
#code
end
if(x==y) {
#code
}
(the first one would pretty much look like it already does, and one
could decide that "do" can be omitted to make it compatible with
existing code.)
In other words it would look just like for iterators (more consistent
Ruby) and at the same time make happy those that want brackets instead
of keywords to delimit if/while/unless: two birds with one stone.
Thank you very much. Anyway Ruby keeps being a great language and I
really love it (though I have not use it much yet).
Diego Virasoro