Re: Type sniffing at runtime

2020-05-15 Thread Alex via Digitalmars-d-learn
On Saturday, 16 May 2020 at 05:22:49 UTC, n0den1te wrote: [...] For example, like this: ´´´ import std; alias types = AliasSeq!( bool, byte, ubyte, short, ushort, int, uint, long, ulong, float, double, real, char, wchar, dchar ); void main() { static foreach(type; types) {

Type sniffing at runtime

2020-05-15 Thread n0den1te via Digitalmars-d-learn
Hi, I am working through the book 'Programming in D' and wanted to take the sample program on http://ddili.org/ders/d.en/types.html, one step further: import std.stdio; void main() { writeln("Type : ", int.stringof); writeln("Length in bytes: ", int.siz

Re: Linker error under Ubuntu

2020-05-15 Thread kinke via Digitalmars-d-learn
On Thursday, 14 May 2020 at 16:09:16 UTC, solidstate1991 wrote: When I try to compile my own project under Ubuntu with dub, I get the following linker error: /usr/bin/ld: .dub/obj/pixelperfectengine_pixelperfecteditor.o: undefined reference to symbol 'inflateEnd' //lib/x86_64-linux-gnu/libz.so

Re: Testing template parameter has given API

2020-05-15 Thread Paul Backus via Digitalmars-d-learn
On Saturday, 16 May 2020 at 01:11:54 UTC, NaN wrote: Howdy, any idea what Im doing wrong? Given a type T i want to test the presence of certain methods. I looked in phobos to see how isInputRange was defined but it didnt really help as all the methods have no parameters and it used some weird l

Re: Testing template parameter has given API

2020-05-15 Thread Adam D. Ruppe via Digitalmars-d-learn
try changing delegate to function, on the type itself it is often function

Testing template parameter has given API

2020-05-15 Thread NaN via Digitalmars-d-learn
Howdy, any idea what Im doing wrong? Given a type T i want to test the presence of certain methods. I looked in phobos to see how isInputRange was defined but it didnt really help as all the methods have no parameters and it used some weird lamda stuff i think. template isPathType(T) { a

Re: Linker error under Ubuntu

2020-05-15 Thread evilrat via Digitalmars-d-learn
On Friday, 15 May 2020 at 23:49:37 UTC, solidstate1991 wrote: Dub should do the linking by itself. How does it know what to link?

Re: Linker error under Ubuntu

2020-05-15 Thread solidstate1991 via Digitalmars-d-learn
On Friday, 15 May 2020 at 03:46:57 UTC, evilrat wrote: Um, pardon the stupid question, but did you just forgot to link it? I can't see a mention of it anywhere in both the old json and dub.sdl, and I don't see subpackages either. (does it links implicitly by the compiler?) Also if it's digg

Re: Can You Expand Arrays into an Argument List?

2020-05-15 Thread surlymoor via Digitalmars-d-learn
On Friday, 15 May 2020 at 19:19:59 UTC, H. S. Teoh wrote: It's possible to do it, but the called function has to support it. If that's not an option, then you're out of luck and probably have to use metaprogramming instead. Here's how to do it: int add(int[] args...) {

Re: Can You Expand Arrays into an Argument List?

2020-05-15 Thread Dennis via Digitalmars-d-learn
On Friday, 15 May 2020 at 19:19:59 UTC, H. S. Teoh wrote: Here's how to do it: int add(int[] args...) { ... // access `args` here as an array } Beware that that language feature, typesafe variadic functions, might become deprecated: https://github.com/dlang/dm

Re: Can You Expand Arrays into an Argument List?

2020-05-15 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, May 15, 2020 at 06:44:52PM +, surlymoor via Digitalmars-d-learn wrote: [...] > I don't often miss JS, but one particular feature that I enjoyed is > the ability to expand arrays into argument lists using a unary > operator. > > Example: add(...[1, 1]) === add(1, 1) // IIRC > > I've b

Re: How to run program with "dmd -i" compiler swich ?

2020-05-15 Thread Vinod K Chandran via Digitalmars-d-learn
On Friday, 15 May 2020 at 14:29:38 UTC, Adam D. Ruppe wrote: use the -run switch to dmd. Make sure it and te d file name are the LAST arguments. dmd -i other_dmd_args_you_need -run yourfile.d Thank you for the reply. Let me try. :)

Re: How to run program with "dmd -i" compiler swich ?

2020-05-15 Thread Vinod K Chandran via Digitalmars-d-learn
On Friday, 15 May 2020 at 18:22:47 UTC, Seb wrote: On Friday, 15 May 2020 at 14:09:00 UTC, Vinod K Chandran wrote: Hi, For some unknown reasons, dub is not working for me. But i can build my program with "dmd -i". But i would like to know if there is any code to run my program with "dmd -i". N

Can You Expand Arrays into an Argument List?

2020-05-15 Thread surlymoor via Digitalmars-d-learn
Hello, I don't often miss JS, but one particular feature that I enjoyed is the ability to expand arrays into argument lists using a unary operator. Example: add(...[1, 1]) === add(1, 1) // IIRC I've been looking in Phobos and the spec, but nothing's popped out to me. Is there a fairly obvio

Re: How to run program with "dmd -i" compiler swich ?

2020-05-15 Thread Seb via Digitalmars-d-learn
On Friday, 15 May 2020 at 14:09:00 UTC, Vinod K Chandran wrote: Hi, For some unknown reasons, dub is not working for me. But i can build my program with "dmd -i". But i would like to know if there is any code to run my program with "dmd -i". Note : "rdmd" is also working but it creates the exe

Re: Best way to refer to the type of a struct inside itself ?

2020-05-15 Thread wjoe via Digitalmars-d-learn
On Friday, 15 May 2020 at 15:24:32 UTC, Ali Çehreli wrote: On 5/15/20 8:04 AM, Paul Backus wrote: [...] Yes, that is a consistent way of explaining it. :) As an off-topic trivia, the same feature is in C++ as well: [...] Ali Awesome. Thank you Ali and Paul :)

Re: Best way to refer to the type of a struct inside itself ?

2020-05-15 Thread Ali Çehreli via Digitalmars-d-learn
On 5/15/20 8:04 AM, Paul Backus wrote: On Friday, 15 May 2020 at 14:55:07 UTC, Ali Çehreli wrote: Additionally, the name of a template when used inside that template means that instance of it. So just say Foo. :) struct Foo(A, B, C, size_t a, size_t b) {   Foo * p; } Ali To expand a little,

Re: Best way to refer to the type of a struct inside itself ?

2020-05-15 Thread Paul Backus via Digitalmars-d-learn
On Friday, 15 May 2020 at 14:55:07 UTC, Ali Çehreli wrote: Additionally, the name of a template when used inside that template means that instance of it. So just say Foo. :) struct Foo(A, B, C, size_t a, size_t b) { Foo * p; } Ali To expand a little, this works because a struct template su

DUB Registry

2020-05-15 Thread Luis via Digitalmars-d-learn
There is a way to make to ignore some branchs and tags? Actually it's pretty annoying when someone publish a fork, and spams with "does not match the original package name" on older tags.

Re: Best way to refer to the type of a struct inside itself ?

2020-05-15 Thread Ali Çehreli via Digitalmars-d-learn
On 5/15/20 7:37 AM, wjoe wrote: On Friday, 15 May 2020 at 13:52:38 UTC, Paul Backus wrote: On Friday, 15 May 2020 at 13:47:43 UTC, wjoe wrote: struct Foo(A, B, C, size_t a, size_t b) {   alias foo_t = Foo!(A, B, C, a, b); // is there a better way to get foo_t ? } typeof(this) Thanks :)

Re: Best way to refer to the type of a struct inside itself ?

2020-05-15 Thread wjoe via Digitalmars-d-learn
On Friday, 15 May 2020 at 13:52:38 UTC, Paul Backus wrote: On Friday, 15 May 2020 at 13:47:43 UTC, wjoe wrote: struct Foo(A, B, C, size_t a, size_t b) { alias foo_t = Foo!(A, B, C, a, b); // is there a better way to get foo_t ? } typeof(this) Thanks :)

Re: How to run program with "dmd -i" compiler swich ?

2020-05-15 Thread Adam D. Ruppe via Digitalmars-d-learn
use the -run switch to dmd. Make sure it and te d file name are the LAST arguments. dmd -i other_dmd_args_you_need -run yourfile.d

Re: How to include my own library in my d program with dub ?

2020-05-15 Thread Vinod K Chandran via Digitalmars-d-learn
On Thursday, 14 May 2020 at 12:57:19 UTC, JN wrote: On Thursday, 14 May 2020 at 12:53:43 UTC, Vinod K Chandran wrote: Hi all, I just build a skeleton of a Gui library(win32 based) for my own purpose. How do i use this in my d programs with dub ? Now, all files are located in a folder called "G

How to run program with "dmd -i" compiler swich ?

2020-05-15 Thread Vinod K Chandran via Digitalmars-d-learn
Hi, For some unknown reasons, dub is not working for me. But i can build my program with "dmd -i". But i would like to know if there is any code to run my program with "dmd -i". Note : "rdmd" is also working but it creates the exe file in temp directory, so my AV is catching it every time. Its

Re: Best way to refer to the type of a struct inside itself ?

2020-05-15 Thread Paul Backus via Digitalmars-d-learn
On Friday, 15 May 2020 at 13:47:43 UTC, wjoe wrote: struct Foo(A, B, C, size_t a, size_t b) { alias foo_t = Foo!(A, B, C, a, b); // is there a better way to get foo_t ? } typeof(this)

Best way to refer to the type of a struct inside itself ?

2020-05-15 Thread wjoe via Digitalmars-d-learn
struct Foo(A, B, C, size_t a, size_t b) { alias foo_t = Foo!(A, B, C, a, b); // is there a better way to get foo_t ? }