July 23, 2004 Re: Can I load an Dynamic Real Array on one line? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Regan Heath | Ilya Minkov and Regan Heath: Thxs for your replys on this subject! :) ------------------------------------------------------------------- "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!" |
July 23, 2004 Re: Can I load an Dynamic Real Array on one line? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Regan Heath | Regan Heath schrieb: >> Naturally, you can leave out the .dup and do a simple assignment, but then you may not write anything into arr because it would be aliased with arr_prototype, which is stored in a constant area. > > No it's not :) OK, even if it's not it's illegal. it just doesn't always work as intended. > This is the problem I have with 'const' currently, in your example the array _reference_ arr_prototype is const, but the data it contains/references is not. > //real arr[] = arr_prototype.dup; //you used C style declaration? > real[] arr = arr_prototype; whoops! i would never write that myself, it's here because i first copied David's code verbatim. :) -eye |
July 24, 2004 Re: Can I load an Dynamic Real Array on one line? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ilya Minkov | On Fri, 23 Jul 2004 14:10:53 +0200, Ilya Minkov <minkov@cs.tum.edu> wrote: > Regan Heath schrieb: > >>> Naturally, you can leave out the .dup and do a simple assignment, but then you may not write anything into arr because it would be aliased with arr_prototype, which is stored in a constant area. >> >> No it's not :) > > OK, even if it's not it's illegal. it just doesn't always work as intended. It has _never_ 'worked' for me, as in, given me a compile time or runtime error saying I cannot modify that const data. I think it's been implemented as I desribed in that "const int[]" means a constant reference to an array of non constant data. >> This is the problem I have with 'const' currently, in your example the array _reference_ arr_prototype is const, but the data it contains/references is not. > > >> //real arr[] = arr_prototype.dup; //you used C style declaration? >> real[] arr = arr_prototype; > > whoops! i would never write that myself, it's here because i first copied David's code verbatim. :) Just checking. :) Regan -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ |
Copyright © 1999-2021 by the D Language Foundation