Re: dub: how to reference a compiled package

2016-02-25 Thread asdf via Digitalmars-d-learn
On Friday, 26 February 2016 at 04:03:15 UTC, BBasile wrote: e.g the DMD equivalent for the two previous example is DMD "sourceThis.d" "folder/interface.di" "folder/binary.a" -ofbin/thesoft You can mix unlinked binaries and text-editor source files on commandline? Didn't know that when I trie

Re: dub: how to reference a compiled package

2016-02-25 Thread Mike Parker via Digitalmars-d-learn
On Friday, 26 February 2016 at 04:03:15 UTC, BBasile wrote: The D interface file must be specified to DUB using "sourceFiles" : ["folder/interface.di"], either in a config or in the globals. The binary, so either a .lib | .a or .obj | .o must be specified to DUB using "DFlags" : ["folder/

Re: dub: how to reference a compiled package

2016-02-25 Thread Mike Parker via Digitalmars-d-learn
On Friday, 26 February 2016 at 03:19:26 UTC, mahdi wrote: Great! Thanks. I was looking for a feature like `jar` files in Java or `assemblies` in C# where all compiled code and metadata/symbols are stored together inside a single binary file. I think same can be implemented for D language an

Minimise and collect by GC when OutOfMemory

2016-02-25 Thread tcak via Digitalmars-d-learn
Would it be a good idea to call "collect" and "minimize" methods of core.memory.GC when OutOfMemory error is received FOR A LONG RUNNING PROGRAM? or there won't be any benefit of that? Example program: A web server that allocates and releases memory from heap continuously.

Re: all functions that have a first arg of type T

2016-02-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 26 February 2016 at 04:21:15 UTC, BBasile wrote: On Friday, 26 February 2016 at 04:19:29 UTC, BBasile wrote: static if (__traits(isStaticFunction,typeof(m2))) static if (__traits(isStaticFunction, __traits(getMember, vulkan_input, m2 Sorry don't copy paste like this there's a

Re: all functions that have a first arg of type T

2016-02-25 Thread BBasile via Digitalmars-d-learn
On Friday, 26 February 2016 at 04:19:29 UTC, BBasile wrote: static if (__traits(isStaticFunction,typeof(m2))) static if (__traits(isStaticFunction, __traits(getMember, vulkan_input, m2 Sorry don't copy paste like this there's a superfluous right paren. static if (__traits(isStaticFunct

Re: all functions that have a first arg of type T

2016-02-25 Thread BBasile via Digitalmars-d-learn
On Friday, 26 February 2016 at 03:57:25 UTC, Nicholas Wilson wrote: foreach(m; __traits(allMembers, vulkan_input)) { static if (m.endsWith("_T")) { foreach(m2; __traits(allMembers, vulkan_input)) { static if (__traits(isStaticFunction,typeof(m2)))// <- what h

Re: dub: how to reference a compiled package

2016-02-25 Thread BBasile via Digitalmars-d-learn
On Thursday, 25 February 2016 at 12:15:42 UTC, mahdi wrote: Hi, Suppose I have a package `mypack` in `~/mypack`. I run `dub` command on this package and have the compiled `mypack` file (OS is Linux). Now I am working on my project. I know how to use the source-code of `mypack` package in th

all functions that have a first arg of type T

2016-02-25 Thread Nicholas Wilson via Digitalmars-d-learn
foreach(m; __traits(allMembers, vulkan_input)) { static if (m.endsWith("_T")) { foreach(m2; __traits(allMembers, vulkan_input)) { static if (__traits(isStaticFunction,typeof(m2)))// <- what here? { enum fn = __traits(getMember,vu

Re: how to initialise const variables

2016-02-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 26 February 2016 at 02:32:44 UTC, Nicholas Wilson wrote: struct A { const (void *) p; } struct B { Aa; this(void * _p) { a.p = _p; } } I cannot change the definition of A how do I initialise b.a.p? Use a constructor for A instead of trying to write

Re: dub: how to reference a compiled package

2016-02-25 Thread mahdi via Digitalmars-d-learn
On Friday, 26 February 2016 at 02:49:20 UTC, Mike Parker wrote: On Thursday, 25 February 2016 at 21:06:59 UTC, mahdi wrote: On Thursday, 25 February 2016 at 16:45:46 UTC, Chris Wright Thanks. Is there a way to use a D library without having access to it's source code? I tried `dmd -lib abcd.d

Re: how to initialise const variables

2016-02-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 26 February 2016 at 02:48:35 UTC, cym13 wrote: On Friday, 26 February 2016 at 02:32:44 UTC, Nicholas Wilson wrote: struct A { const (void *) p; } struct B { Aa; this(void * _p) { a.p = _p; } } I cannot change the definition of A how do I initialise b

Re: dub: how to reference a compiled package

2016-02-25 Thread Mike Parker via Digitalmars-d-learn
On Friday, 26 February 2016 at 02:49:20 UTC, Mike Parker wrote: The compiler needs to know about S and its types, and it needs S and its *members*

Re: dub: how to reference a compiled package

2016-02-25 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 25 February 2016 at 21:06:59 UTC, mahdi wrote: On Thursday, 25 February 2016 at 16:45:46 UTC, Chris Wright Thanks. Is there a way to use a D library without having access to it's source code? I tried `dmd -lib abcd.d` which creates a static library. But still I need to specify pa

Re: how to initialise const variables

2016-02-25 Thread cym13 via Digitalmars-d-learn
On Friday, 26 February 2016 at 02:32:44 UTC, Nicholas Wilson wrote: struct A { const (void *) p; } struct B { Aa; this(void * _p) { a.p = _p; } } I cannot change the definition of A how do I initialise b.a.p? As you did: void main() { int i = 42;

how to initialise const variables

2016-02-25 Thread Nicholas Wilson via Digitalmars-d-learn
struct A { const (void *) p; } struct B { Aa; this(void * _p) { a.p = _p; } } I cannot change the definition of A how do I initialise b.a.p?

Re: how do you append arrays?

2016-02-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/25/16 4:39 PM, asdf wrote: if(line != "" && line != history[0]) { string[] x = [line]; foreach(string i; history[0..99]) x ~= i; history = x; } ugh! history = line ~ history[0 .. $ - 1]; What you may want to consider is making his

Re: Accessing all data in TypeTupple (AliasSeq) and stringify them

2016-02-25 Thread Ali Çehreli via Digitalmars-d-learn
On 02/25/2016 12:53 PM, Voitech wrote: template TupleToString(TList...){ string a; foreach(T;TList){ // Error: declaration expected, not 'foreach' a~=T.stringof; } enum string TupleToString=a; } Of course i can use template function, but wanted to know if can omit

Re: Accessing all data in TypeTupple (AliasSeq) and stringify them

2016-02-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 25 February 2016 at 20:53:12 UTC, Voitech wrote: On Thursday, 25 February 2016 at 14:29:30 UTC, Nicholas Wilson wrote: On Thursday, 25 February 2016 at 13:16:43 UTC, Voitech wrote: [...] You can (see std.meta/(std.traits?) , with recursive templates), but there is nothing stoppi

Re: Calling python code from D

2016-02-25 Thread asdf via Digitalmars-d-learn
On Thursday, 25 February 2016 at 21:46:40 UTC, asdf wrote: Hi, me again. I'm having trouble making a demonstration and not sure if is obsolete or not anyways. :/ Anyways take a look here. http://www.tutorialspoint.com/python/python_further_extensions.htm http://dlang.org/spec/interfaceToC

Re: Calling python code from D

2016-02-25 Thread jmh530 via Digitalmars-d-learn
On Thursday, 25 February 2016 at 21:46:40 UTC, asdf wrote: I haven't tried this myself but D is supposed to have excellent interface to C code. Perhaps you can go that route. http://stackoverflow.com/questions/145270/calling-c-c-from-python That question is the reverse, calling C from python

Re: Installing DUB on OSX

2016-02-25 Thread Joel via Digitalmars-d-learn
On Thursday, 25 February 2016 at 11:06:09 UTC, Jacob Carlborg wrote: On 2016-02-24 23:11, Joel wrote: Error: Error writing file '../../../.dub/packages/dsfml-2.1.0/libdsfml_system.a' Joels-MacBook-Pro:DGuy joelcnz$ Is the full path of ../../../.dub/packages/dsfml-2.1.0 writable? It is path:

Re: Calling python code from D

2016-02-25 Thread asdf via Digitalmars-d-learn
On Thursday, 25 February 2016 at 21:40:45 UTC, Wyatt wrote: I have a project I started in Python before I realised I really don't enjoy Python. It's been on the back-burner for a few years and I'd like to start again in D, but there's a particular python module (Mutagen) that I outright refuse

Calling python code from D

2016-02-25 Thread Wyatt via Digitalmars-d-learn
I have a project I started in Python before I realised I really don't enjoy Python. It's been on the back-burner for a few years and I'd like to start again in D, but there's a particular python module (Mutagen) that I outright refuse to reimplement. What's the state of the art in calling Pyt

Re: how do you append arrays?

2016-02-25 Thread asdf via Digitalmars-d-learn
On Thursday, 25 February 2016 at 19:21:31 UTC, Steven Schveighoffer wrote: On 2/25/16 2:12 PM, Steven Schveighoffer wrote: I believe you could use std.algorithm.copy, but probably need to do it with retro as well. Heh, or of course use memmove :) -Steve I got the history list working this

Re: Installing DUB on OSX

2016-02-25 Thread Joel via Digitalmars-d-learn
On Thursday, 25 February 2016 at 11:06:09 UTC, Jacob Carlborg wrote: On 2016-02-24 23:11, Joel wrote: Error: Error writing file '../../../.dub/packages/dsfml-2.1.0/libdsfml_system.a' Joels-MacBook-Pro:DGuy joelcnz$ Is the full path of ../../../.dub/packages/dsfml-2.1.0 writable? .dub is gra

Re: How to better organize dub project to get 3 exe from same codebase?

2016-02-25 Thread Luis via Digitalmars-d-learn
On Thursday, 25 February 2016 at 20:55:33 UTC, Suliman wrote: On Thursday, 25 February 2016 at 19:09:59 UTC, Suliman wrote: Where to store shared classes? { "name": "123", "authors": [ "Suliman" ], "description": "A minimal D application.",

Re: dub: how to reference a compiled package

2016-02-25 Thread mahdi via Digitalmars-d-learn
On Thursday, 25 February 2016 at 16:45:46 UTC, Chris Wright wrote: On Thu, 25 Feb 2016 12:15:42 +, mahdi wrote: Hi, Suppose I have a package `mypack` in `~/mypack`. I run `dub` command on this package and have the compiled `mypack` file (OS is Linux). Now I am working on my project. I

Re: How to better organize dub project to get 3 exe from same codebase?

2016-02-25 Thread Suliman via Digitalmars-d-learn
On Thursday, 25 February 2016 at 19:09:59 UTC, Suliman wrote: Where to store shared classes? { "name": "123", "authors": [ "Suliman" ], "description": "A minimal D application.", "copyright": "Copyright © 2016, Suliman", "license":

Re: Accessing all data in TypeTupple (AliasSeq) and stringify them

2016-02-25 Thread Voitech via Digitalmars-d-learn
On Thursday, 25 February 2016 at 14:29:30 UTC, Nicholas Wilson wrote: On Thursday, 25 February 2016 at 13:16:43 UTC, Voitech wrote: Hi, I have some code processing functions definition in compile time, I want to override them in some other class but not explicitly so created this code: templa

Re: How to detect if an array if dynamic or static

2016-02-25 Thread Ali Çehreli via Digitalmars-d-learn
On 02/25/2016 04:47 AM, sigod wrote: > void bar(ref int[] arr) > > Code wouldn't compile if you try to pass static array as `ref` argument. To qualify further, static arrays cannot be passed as slice references because although there is an automatic slicing of static arrays, such slices a

Re: how do you append arrays?

2016-02-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/25/16 2:12 PM, Steven Schveighoffer wrote: I believe you could use std.algorithm.copy, but probably need to do it with retro as well. Heh, or of course use memmove :) -Steve

Re: How to detect if an array if dynamic or static

2016-02-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/24/16 9:08 PM, Adam D. Ruppe wrote: On Thursday, 25 February 2016 at 01:31:17 UTC, Chris Wright wrote: When you get to GC-allocated stuff, there's no way to tell. The GC is easy, you can simply ask it: http://dpldocs.info/experimental-docs/core.memory.GC.addrOf.1.html "If p references m

Re: how do you append arrays?

2016-02-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/25/16 8:24 AM, asdf wrote: On Thursday, 25 February 2016 at 13:06:10 UTC, cym13 wrote: In D the binary operator "~" is used to concatenate both strings (arrays of characters) and arrays. (also the ~= operator is equivalent to lhs = lhs ~ rhs Nic Just a precision: "lhs ~= rhs" isn't ex

Re: How to better organize dub project to get 3 exe from same codebase?

2016-02-25 Thread Suliman via Digitalmars-d-learn
Where to store shared classes?

Re: How to better organize dub project to get 3 exe from same codebase?

2016-02-25 Thread Zardoz via Digitalmars-d-learn
On Thursday, 25 February 2016 at 18:57:08 UTC, Suliman wrote: I have got 3 small projects that have shared code base. At compile time they use few same classes. On runtime they use same config file. How to better to organize work with dub? Try with subpacjages like I did : name "dedcpu" autho

How to better organize dub project to get 3 exe from same codebase?

2016-02-25 Thread Suliman via Digitalmars-d-learn
I have got 3 small projects that have shared code base. At compile time they use few same classes. On runtime they use same config file. How to better to organize work with dub?

Re: Shared static constructors from C# EXE

2016-02-25 Thread Thalamus via Digitalmars-d-learn
On Thursday, 25 February 2016 at 16:05:37 UTC, Benjamin Thaut wrote: On Thursday, 25 February 2016 at 14:42:14 UTC, Thalamus wrote: your entry point. Hi Guillaume, Thanks for responding so quickly! I had found that wiki page before and I'd been following the "DLLs with a C Interface" sectio

Re: How to detect if an array if dynamic or static

2016-02-25 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 24 February 2016 at 21:48:14 UTC, mahdi wrote: Suppose we have a function like this: void diss(int[] array) ... How can we detect is `array` is static (fixed size) or dynamic, inside the function body? I don't see that anyone has mentioned it but: https://dlang.org/phobos/std_

Re: dub: how to reference a compiled package

2016-02-25 Thread Chris Wright via Digitalmars-d-learn
On Thu, 25 Feb 2016 12:15:42 +, mahdi wrote: > Hi, > > Suppose I have a package `mypack` in `~/mypack`. I run `dub` command on > this package and have the compiled `mypack` file (OS is Linux). > > Now I am working on my project. I know how to use the source-code of > `mypack` package in the

Re: How to detect if an array if dynamic or static

2016-02-25 Thread Chris Wright via Digitalmars-d-learn
On Thu, 25 Feb 2016 02:08:18 +, Adam D. Ruppe wrote: > On Thursday, 25 February 2016 at 01:31:17 UTC, Chris Wright wrote: >> When you get to GC-allocated stuff, there's no way to tell. > > The GC is easy, you can simply ask it: > > http://dpldocs.info/experimental-docs/core.memory.GC.addrOf.

Re: Shared static constructors from C# EXE

2016-02-25 Thread Benjamin Thaut via Digitalmars-d-learn
On Thursday, 25 February 2016 at 14:42:14 UTC, Thalamus wrote: your entry point. Hi Guillaume, Thanks for responding so quickly! I had found that wiki page before and I'd been following the "DLLs with a C Interface" section closely. I had forgotten to add -shared when building the DLL, but

Re: Dynamic pitch shift

2016-02-25 Thread Luis via Digitalmars-d-learn
On Wednesday, 24 February 2016 at 11:17:27 UTC, Tanel Tagaväli wrote: Sorry for the confusing state of the codebase. Only the saw wave generator is currently functional, the `saw` and `sine` functions are not used and should be left out of analysis. Also, audio output is only to ALSA. Be c

Re: Shared static constructors from C# EXE

2016-02-25 Thread Thalamus via Digitalmars-d-learn
On Thursday, 25 February 2016 at 14:07:21 UTC, Guillaume Piolat wrote: On Thursday, 25 February 2016 at 14:01:30 UTC, Thalamus wrote: I don't control the EXE itself and the code I write to interface with it must be either C# or JavaScript, but this repros with a test C# driver EXE as well. The

Re: Accessing all data in TypeTupple (AliasSeq) and stringify them

2016-02-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 25 February 2016 at 13:16:43 UTC, Voitech wrote: Hi, I have some code processing functions definition in compile time, I want to override them in some other class but not explicitly so created this code: template MixinFunction(alias attributes,alias returnType,alias name,alias pa

Re: Shared static constructors from C# EXE

2016-02-25 Thread Guillaume Piolat via Digitalmars-d-learn
On Thursday, 25 February 2016 at 14:01:30 UTC, Thalamus wrote: I don't control the EXE itself and the code I write to interface with it must be either C# or JavaScript, but this repros with a test C# driver EXE as well. The interfacing C# code can only be aware of the exposed D DLL functions de

Shared static constructors from C# EXE

2016-02-25 Thread Thalamus via Digitalmars-d-learn
Hi everyone, I looked in the forums and Google in general but I didn't find a similar question, and I'm stumped. I have a scenario where a set of classes must be registered with a class mapper and then instantiated via a factory. The classes themselves are agnostic of one another, and all int

Re: How to detect if an array if dynamic or static

2016-02-25 Thread asdf via Digitalmars-d-learn
On Wednesday, 24 February 2016 at 21:48:14 UTC, mahdi wrote: Suppose we have a function like this: void diss(int[] array) ... How can we detect is `array` is static (fixed size) or dynamic, inside the function body? I don't understand what I'm doing but got a proof of concept for you. This

Re: how do you append arrays?

2016-02-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 25 February 2016 at 13:38:56 UTC, ag0aep6g wrote: On 25.02.2016 14:33, Nicholas Wilson wrote: Note that D has zero based array indexing so assuming your array has 100 elements history[1..100] is going one past the end of the array. No, that's fine. `history[1..100]` gives you 99 e

Re: how do you append arrays?

2016-02-25 Thread ag0aep6g via Digitalmars-d-learn
On 25.02.2016 14:33, Nicholas Wilson wrote: Note that D has zero based array indexing so assuming your array has 100 elements history[1..100] is going one past the end of the array. No, that's fine. `history[1..100]` gives you 99 elements starting at index 1, i.e. all except the first one.

Re: how do you append arrays?

2016-02-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 25 February 2016 at 13:24:09 UTC, asdf wrote: On Thursday, 25 February 2016 at 13:06:10 UTC, cym13 wrote: In D the binary operator "~" is used to concatenate both strings (arrays of characters) and arrays. (also the ~= operator is equivalent to lhs = lhs ~ rhs Nic Just a pre

Re: how do you append arrays?

2016-02-25 Thread asdf via Digitalmars-d-learn
On Thursday, 25 February 2016 at 13:06:10 UTC, cym13 wrote: In D the binary operator "~" is used to concatenate both strings (arrays of characters) and arrays. (also the ~= operator is equivalent to lhs = lhs ~ rhs Nic Just a precision: "lhs ~= rhs" isn't exactly equivalent to "lhs = lh

Accessing all data in TypeTupple (AliasSeq) and stringify them

2016-02-25 Thread Voitech via Digitalmars-d-learn
Hi, I have some code processing functions definition in compile time, I want to override them in some other class but not explicitly so created this code: template MixinFunction(alias attributes,alias returnType,alias name,alias parameters,alias bodyy){ enum string MixinFunction = for

Re: how do you append arrays?

2016-02-25 Thread cym13 via Digitalmars-d-learn
On Thursday, 25 February 2016 at 12:58:54 UTC, Nicholas Wilson wrote: On Thursday, 25 February 2016 at 12:53:37 UTC, asdf wrote: I'm trying to make a terminal input preprocessor with alias/shortcuts and history. import std.stdio; void main() { string line; string[] history; line

Re: how do you append arrays?

2016-02-25 Thread asdf via Digitalmars-d-learn
On Thursday, 25 February 2016 at 12:58:54 UTC, Nicholas Wilson wrote: In D the binary operator "~" is used to concatenate both strings (arrays of characters) and arrays. (also the ~= operator is equivalent to lhs = lhs ~ rhs Nic It worked! A link from someone else's question suggested `ne

Re: how do you append arrays?

2016-02-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 25 February 2016 at 12:53:37 UTC, asdf wrote: I'm trying to make a terminal input preprocessor with alias/shortcuts and history. import std.stdio; void main() { string line; string[] history; line = readln(); foreach(int i; 0..100) history = history + [""]; // XX

Re: how do you append arrays?

2016-02-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 25 February 2016 at 12:53:37 UTC, asdf wrote: I'm trying to make a terminal input preprocessor with alias/shortcuts and history. import std.stdio; void main() { string line; string[] history; line = readln(); foreach(int i; 0..100) history = history + [""]; // XX

how do you append arrays?

2016-02-25 Thread asdf via Digitalmars-d-learn
I'm trying to make a terminal input preprocessor with alias/shortcuts and history. import std.stdio; void main() { string line; string[] history; line = readln(); foreach(int i; 0..100) history = history + [""]; // XXX while(!stdin.eof) { writeln(line); if

Re: How to detect if an array if dynamic or static

2016-02-25 Thread sigod via Digitalmars-d-learn
On Thursday, 25 February 2016 at 12:18:07 UTC, mahdi wrote: On Thursday, 25 February 2016 at 11:50:02 UTC, sigod wrote: On Thursday, 25 February 2016 at 10:03:08 UTC, mahdi wrote: Thanks. So when we define the function, we MUST specify the array size to be able to accept a static array? Can't

Re: How to detect if an array if dynamic or static

2016-02-25 Thread sigod via Digitalmars-d-learn
On Thursday, 25 February 2016 at 12:18:07 UTC, mahdi wrote: On Thursday, 25 February 2016 at 11:50:02 UTC, sigod wrote: On Thursday, 25 February 2016 at 10:03:08 UTC, mahdi wrote: Thanks. So when we define the function, we MUST specify the array size to be able to accept a static array? Can't

Re: How to detect if an array if dynamic or static

2016-02-25 Thread mahdi via Digitalmars-d-learn
On Thursday, 25 February 2016 at 11:50:02 UTC, sigod wrote: On Thursday, 25 February 2016 at 10:03:08 UTC, mahdi wrote: Thanks. So when we define the function, we MUST specify the array size to be able to accept a static array? Can't we just define a function which can accept any static array

dub: how to reference a compiled package

2016-02-25 Thread mahdi via Digitalmars-d-learn
Hi, Suppose I have a package `mypack` in `~/mypack`. I run `dub` command on this package and have the compiled `mypack` file (OS is Linux). Now I am working on my project. I know how to use the source-code of `mypack` package in the project but what if I only have the compiled binary? How c

Re: How to detect if an array if dynamic or static

2016-02-25 Thread sigod via Digitalmars-d-learn
On Thursday, 25 February 2016 at 10:03:08 UTC, mahdi wrote: Thanks. So when we define the function, we MUST specify the array size to be able to accept a static array? Can't we just define a function which can accept any static array with any size? (e.g. a function to calculate average of a s

Re: tell if __traits(allMembers, ... ) is an enum (not manifest constant)

2016-02-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 25 February 2016 at 08:40:00 UTC, nkgu wrote: On Thursday, 25 February 2016 at 04:55:09 UTC, Nicholas Wilson wrote: oops should be writeln(typeof(__traits(getMember, vulkan_input, m)).stringof); that compiles but still prints nothing try pragma(msg, typeof(__traits(getMember,

Re: Installing DUB on OSX

2016-02-25 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-02-24 23:11, Joel wrote: Error: Error writing file '../../../.dub/packages/dsfml-2.1.0/libdsfml_system.a' Joels-MacBook-Pro:DGuy joelcnz$ Is the full path of ../../../.dub/packages/dsfml-2.1.0 writable? -- /Jacob Carlborg

Re: Const vs Non const method

2016-02-25 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 25 February 2016 at 10:44:49 UTC, Andrea Fontana wrote: Check this simple code: http://dpaste.dzfl.pl/2772c9144f1c I can't understand how to minimize code duplication for function like get(). Of course on real case body is much bigger and complex than that. The only way I found

Re: Const vs Non const method

2016-02-25 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 25 February 2016 at 10:48:34 UTC, Namespace wrote: Try inout: import std.stdio; struct Inner { int field = 3; } struct Test { auto get() inout { return inner; } private Inner inner; } void main() { {

Re: Const vs Non const method

2016-02-25 Thread Namespace via Digitalmars-d-learn
Try inout: import std.stdio; struct Inner { int field = 3; } struct Test { auto get() inout { return inner; } private Inner inner; } void main() { { Test test; test.get.field = 4; }

Const vs Non const method

2016-02-25 Thread Andrea Fontana via Digitalmars-d-learn
Check this simple code: http://dpaste.dzfl.pl/2772c9144f1c I can't understand how to minimize code duplication for function like get(). Of course on real case body is much bigger and complex than that. The only way I found is to move the body of function inside a mixin template: mixin templ

Re: How to detect if an array if dynamic or static

2016-02-25 Thread Kagamin via Digitalmars-d-learn
void diss(int n)(ref int[n] array) { } But to consume array of any size, just take dynamic array as parameter.

How to detect if an array if dynamic or static

2016-02-25 Thread mahdi via Digitalmars-d-learn
Thanks. So when we define the function, we MUST specify the array size to be able to accept a static array? Can't we just define a function which can accept any static array with any size? (e.g. a function to calculate average of a static int array of any size)?

Re: tell if __traits(allMembers, ... ) is an enum (not manifest constant)

2016-02-25 Thread nkgu via Digitalmars-d-learn
On Thursday, 25 February 2016 at 04:55:09 UTC, Nicholas Wilson wrote: oops should be writeln(typeof(__traits(getMember, vulkan_input, m)).stringof); that compiles but still prints nothing try pragma(msg, typeof(__traits(getMember, vulkan_input, m)).stringof); because at compile time the