I haven't started reading Andrei's chapter on arrays yet. I hope I won't find
out that the following behavior is expected. :)
import std.cstream;
void modify(int[] a)
{
a[0] = 1;
a ~= 2;
dout.writefln("During: ", a);
}
void main()
{
int[] a = [ 0 ];
dout.writefln("Before:
== Quote from Ali Cehreli (acehr...@yahoo.com)'s article
> I haven't started reading Andrei's chapter on arrays yet. I hope I won't find
out that the following behavior is expected. :)
> import std.cstream;
> void modify(int[] a)
> {
> a[0] = 1;
> a ~= 2;
> dout.writefln("During: ", a);
Ali Cehreli schrieb:
> I haven't started reading Andrei's chapter on arrays yet. I hope I won't find
> out that the following behavior is expected. :)
>
> import std.cstream;
>
> void modify(int[] a)
> {
> a[0] = 1;
> a ~= 2;
>
> dout.writefln("During: ", a);
> }
>
> void main()
>
dsimcha wrote:
== Quote from Ali Cehreli (acehr...@yahoo.com)'s article
I haven't started reading Andrei's chapter on arrays yet. I hope I won't find
out that the following behavior is expected. :)
import std.cstream;
void modify(int[] a)
{
a[0] = 1;
a ~= 2;
dout.writefln("During:
"Frank Benoit" wrote in message
news:hcvff9$9c...@digitalmars.com...
> Ali Cehreli schrieb:
>> I haven't started reading Andrei's chapter on arrays yet. I hope I won't
>> find out that the following behavior is expected. :)
>>
>> import std.cstream;
>>
>> void modify(int[] a)
>> {
>> a[0] =
dsimcha wrote:
== Quote from Ali Cehreli (acehr...@yahoo.com)'s article
I haven't started reading Andrei's chapter on arrays yet. I hope I won't find
out that the following behavior is expected. :)
import std.cstream;
void modify(int[] a)
{
a[0] = 1;
a ~= 2;
dout.writefln("During:
Thanks for all the responses.
And yes, I know that 'ref' is what works for me here. I am trying to figure out
whether I should develop a guideline like "always pass arrays with 'ref', or
you may face surprises."
I understand it very well now and was able to figure out a way to cause some
bugs.
Ali Cehreli wrote:
Thanks for all the responses.
And yes, I know that 'ref' is what works for me here. I am trying to figure out whether I
should develop a guideline like "always pass arrays with 'ref', or you may face
surprises."
I understand it very well now and was able to figure out a way
Ali Cehreli wrote...
This helps me with the meaning of in, out & ref.
http://bayimg.com/NaeOgaaCC
Andrei Alexandrescu, el 5 de noviembre a las 16:10 me escribiste:
> Ali Cehreli wrote:
> >Thanks for all the responses.
> >
> >And yes, I know that 'ref' is what works for me here. I am trying to figure
> >out whether I should develop a guideline like "always pass arrays with
> >'ref', or you ma
Leandro Lucarella wrote:
Andrei Alexandrescu, el 5 de noviembre a las 16:10 me escribiste:
Ali Cehreli wrote:
Thanks for all the responses.
And yes, I know that 'ref' is what works for me here. I am trying to figure out whether I
should develop a guideline like "always pass arrays with 'ref'
Travis Boucher, el 5 de noviembre a las 20:44 me escribiste:
> >>>I don't think that this is easy to explain to a learner; and I think that
> >>>is a good indicator that there is a problem with these semantics.
> >>The ball is in your court to define better semantics.
> >
> >Just make arrays a re
I am not fully against pass-by-ref arrays, I just think in passing by
reference all of the time could have some performance implications.
OK, make 2 different types then: slices (value types, can't append, they
are only a view on other's data) and dynamic arrays (reference type, can
append, but
"Leandro Lucarella" wrote in message
news:20091106035612.gi3...@llucax.com.ar...
>>
>> I am not fully against pass-by-ref arrays, I just think in passing by
>> reference all of the time could have some performance implications.
>
> OK, make 2 different types then: slices (value types, can't appe
On 06/11/2009 07:07, Bob Jones wrote:
"Leandro Lucarella" wrote in message
news:20091106035612.gi3...@llucax.com.ar...
I am not fully against pass-by-ref arrays, I just think in passing by
reference all of the time could have some performance implications.
OK, make 2 different types then: sl
Andrei Alexandrescu Wrote:
> Ali Cehreli wrote:
> > I don't think that this is easy to explain to a learner; and I think that
> > is a good indicator that there is a problem with these semantics.
>
> The ball is in your court to define better semantics.
>
> Andrei
I thought I passed the ball
You can create DynamicArray and RandomAccessRange already now.
Currently int[] a is very intuitive in its purpose, its just some of the
implementation details that get confusing.
int doSomething(in int[]) a)
tells me doSomething is going to process an int array of any size and
not modify it
gzp Wrote:
> I think problem is that, dynamic arrays and slices are NOT the same.
I agree with most of what you wrote, but I can't see that in the current
implementation.
> They have a common subset of interfaces (length, at, slice(maybe)), but
> they are just different. An array owns it's el
D2's "slice" is different than some other languages'. :)
It's okay to change/create new semantics for new languages. It's a must
have to develop new features as long as they make sense.
But think as a newbie to programming for a while.
If you've just learned of arrays and slices and hardly kn
19 matches
Mail list logo