On 4/27/2014 9:32 PM, Ali Çehreli wrote:
fOn 04/27/2014 06:00 PM, David Held wrote:
> I would like to do something like this:
>
> Foo[Bar][Baz] nestedAA;
> auto innerAA = nestedAA[someBaz];
> innerAA[someBar] = someFoo;
> assert(someFoo in nestedAA[someBaz]);
in operator uses a key, not a
Could anyone please explain to me, why do I have error message on
this piece of code?
alias short Type1;
alias Type1[100]* Type2; // pointer to an array
struct Type3
{
Type2 f
}
void foo()
{
Type3* b;
Type1 d;
d = b.f[10]; // compilation error: cannot implicitly convert
expres
On Monday, 28 April 2014 at 08:58:41 UTC, Andrey wrote:
Could anyone please explain to me, why do I have error message
on this piece of code?
alias short Type1;
alias Type1[100]* Type2; // pointer to an array
struct Type3
{
Type2 f
}
void foo()
{
Type3* b;
Type1 d;
d = b.f[10]
not a bug.
b.f[10] is indexing the pointer to the array, not the array
itself.
b.f[0][10] is indexing the array (with the 10), but I would
argue it is better to write *(b.f)[10] so as to be clear that f
is not an array.
thank you, John.
compiler said that '*(b.f)[10]' is deprecated, and I
On Monday, 28 April 2014 at 09:36:08 UTC, Andrey wrote:
not a bug.
b.f[10] is indexing the pointer to the array, not the array
itself.
b.f[0][10] is indexing the array (with the 10), but I would
argue it is better to write *(b.f)[10] so as to be clear that
f is not an array.
thank you, Jo
Andrey:
Could anyone please explain to me, why do I have error message
on this piece of code?
In this thread you are doing some mistakes. This code seems OK:
alias TData = short;
alias TArray = TData[100];
struct MyStruct {
TArray* arrPtr;
}
void main() {
MyStruct* t3 = new MyStruct
I need an array that contains pointers to types created via
template. To stick to my usual example:
Person!(string)
How can I make an array with pointers to concrete "instances" of
Person!(string)?
Something like this only with pointers, i.e. buf holds pointers
to concrete Person!(string)s:
Chris:
I need an array that contains pointers to types created via
template. To stick to my usual example:
Person!(string)
How can I make an array with pointers to concrete "instances"
of Person!(string)?
Every template creates a new type, so you can't put them as they
are in an array. Th
On Monday, 28 April 2014 at 10:32:18 UTC, bearophile wrote:
Chris:
I need an array that contains pointers to types created via
template. To stick to my usual example:
Person!(string)
How can I make an array with pointers to concrete "instances"
of Person!(string)?
Every template creates a
On Monday, 28 April 2014 at 10:32:18 UTC, bearophile wrote:
Chris:
I need an array that contains pointers to types created via
template. To stick to my usual example:
Person!(string)
How can I make an array with pointers to concrete "instances"
of Person!(string)?
Every template creates a
On Monday, 28 April 2014 at 10:40:49 UTC, Chris wrote:
So there is no way of filling an array with something like
Person!(string) *pptr;
foreach(person; people) {
buf ~= &person;
}
Person!(string)*[] arr;
Like this?
On Monday, 28 April 2014 at 10:44:18 UTC, Rene Zwanenburg wrote:
On Monday, 28 April 2014 at 10:40:49 UTC, Chris wrote:
So there is no way of filling an array with something like
Person!(string) *pptr;
foreach(person; people) {
buf ~= &person;
}
Person!(string)*[] arr;
Like this?
Exactl
Chris:
So there is no way of filling an array with something like
Person!(string) *pptr;
foreach(person; people) {
buf ~= &person;
}
So you want an array filled with instances of the same
instantiation, sorry, I misunderstood your problem for a more
complex one :-)
Bye,
bearophile
On Monday, 28 April 2014 at 11:04:17 UTC, bearophile wrote:
Chris:
So there is no way of filling an array with something like
Person!(string) *pptr;
foreach(person; people) {
buf ~= &person;
}
So you want an array filled with instances of the same
instantiation, sorry, I misunderstood yo
bearophile, John, probably, my example was not clear...
The code below works.
alias short Type1;
alias Type1[100]* Type2; // if I take out '*' I will have to type
it everywhere, because arrays in D2 always 'by value'
struct Type3
{
Type1 key;
int flags;
int arrLen;
Andrey:
alias short Type1;
The "alias X Y;" syntax is going to be deprecated, so use "alias
Y = X;" if your compiler already supports it.
alias Type1[100]* Type2; // if I take out '*' I will have to
type it everywhere, because arrays in D2 always 'by value'
Adding the * everywhere could
DMD tells me "Error: variable m cannot be read at compile time",
but why ?
[code]
struct MyStruct {
float float_value = 0.0f ;
ubyte ubyte_value = 2 ;
}
enum members = [ __traits( allMembers , MyStruct ) ] ;
foreach( m ; members ) {
mixin( "writeln( " ~ m ~ " , \" : \" , ( My
On Monday, 28 April 2014 at 13:52:52 UTC, ParticlePeter wrote:
DMD tells me "Error: variable m cannot be read at compile
time", but why ?
Because 'static foreach' is not an explicit feature yet, so it
depends on the context. When you wrap the trait via:
[__traits(allMembers, MyStruct)]
You'
On Mon, 28 Apr 2014 06:04:53 -0400, John Colvin
wrote:
On Monday, 28 April 2014 at 09:36:08 UTC, Andrey wrote:
not a bug.
b.f[10] is indexing the pointer to the array, not the array itself.
b.f[0][10] is indexing the array (with the 10), but I would argue it
is better to write *(b.f)[10]
On Monday, 28 April 2014 at 13:57:56 UTC, Andrej Mitrovic wrote:
On Monday, 28 April 2014 at 13:52:52 UTC, ParticlePeter wrote:
DMD tells me "Error: variable m cannot be read at compile
time", but why ?
Because 'static foreach' is not an explicit feature yet, so it
depends on the context. Whe
On 4/28/14, ParticlePeter via Digitalmars-d-learn
wrote:
> I found the code with parenthesis in the dlang __traits docs and
> also Philippe Sigauds "D Templates", and I haven't seen any other
> example which works without them. So, when to use which syntax (
> for which purpose ) ?
If you need to
On Monday, 28 April 2014 at 00:52:50 UTC, ketmar wrote:
module my.module;
public import other.module;
…
module mainprogram;
import my.module;
now i can access other.module symbols without qualifiers
and another case:
module mainprogram;
import zmod = my.module;
now i CAN'T access other.modul
On Monday, 28 April 2014 at 14:02:33 UTC, Steven Schveighoffer
wrote:
On Mon, 28 Apr 2014 06:04:53 -0400, John Colvin
wrote:
On Monday, 28 April 2014 at 09:36:08 UTC, Andrey wrote:
not a bug.
b.f[10] is indexing the pointer to the array, not the array
itself.
b.f[0][10] is indexing the a
On 04/28/2014 12:12 AM, David Held wrote:
> Here is a compilable example which fails:
>
> void main()
> {
> double[int][string] nestedAA;
> nestedAA["test"] = null;
I think I see what's going on. The line above has almost no effect. For
example, it does not populate "test" with an em
On Mon, Apr 28, 2014 at 5:45 PM, Andrej Mitrovic via
Digitalmars-d-learn wrote:
> If you need to store the tuple as an array to some variable, then you
> would use that syntax. It all depends on what you're trying to do from
> the call site. Ultimately it won't matter much once we finally get a
>
On Monday, 28 April 2014 at 17:40:54 UTC, Philippe Sigaud via
Digitalmars-d-learn wrote:
On Mon, Apr 28, 2014 at 5:45 PM, Andrej Mitrovic via
Digitalmars-d-learn wrote:
If you need to store the tuple as an array to some variable,
then you
would use that syntax. It all depends on what you're tr
On Mon, Apr 28, 2014 at 8:20 PM, Dicebot via Digitalmars-d-learn
wrote:
> You can do the same iterating directly over allMembers list, why would you
> prefer array here?
Hmm, indeed. One advantage would be to get a range, and thus the power
and filtering, mapping and co.
synchronized class EventLog{
void opCall(string s){
std.file.append("logfile.txt", s);
}
}
shared EventLog eventLog;
Pleas, is it multithread safe and prefered way?
On 04/28/2014 01:16 PM, xtimoner wrote:
> synchronized class EventLog{
> void opCall(string s){
> std.file.append("logfile.txt", s);
> }
> }
>
> shared EventLog eventLog;
>
> Pleas, is it multithread safe and prefered way?
Only if there is only one EventLog object. A synchroni
On Monday, 28 April 2014 at 10:40:49 UTC, Chris wrote:
Person!(string) *pptr;
Just wanted to point out, the above is C style and not
recommended.
Person!(string)* pptr, pptr2, pptr3;
In D the pointer is part of the type not the variable (all three
are pointers, unlike C where only the
Ok, thanks a lot..
About dynamic arrays: I haven't found any information about
internal representation of the D structures. E.g. do dynamic
arrays have reference counter?
Nevermind, I'm gonna use Type2[0] syntax.
31 matches
Mail list logo