Re: const of AliasSeq is silently ignored

2019-04-08 Thread Ali Çehreli via Digitalmars-d-learn
On 04/08/2019 12:56 PM, Yuxuan Shui wrote: In this example:     const(AliasSeq!(int, int)) a; I would expect that to mean a type list (int, int) that cannot be modified, meaning that it is not allowed to change it from (int, int).     pragma(msg, typeof(a)); // (int, int) Makes sense

Re: Overloads not returning appropriate info. [Field reflunkory]

2019-04-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 6 April 2019 at 12:20:28 UTC, Alex wrote: Error: variable `std.traits.ParameterDefaults!(foo).Get!1u.Get` only parameters or stack based variables can be `inout` so i think that is a bug in the phobos library see:

Re: Overloads not returning appropriate info. [Field reflunkory]

2019-04-08 Thread Walter Bright via Digitalmars-d-learn
On 4/8/2019 7:39 AM, Alex wrote: My point is that you are going ape shit over using T.stringof, you posted no I mean, half the shit in __traits looks like it could be in std.traits and there Please tone down both the aggressiveness and the use of cuss words, and use professional demeanor.

Re: Iterate/sort associative array by value?

2019-04-08 Thread Seb via Digitalmars-d-learn
On Monday, 8 April 2019 at 18:04:28 UTC, kdevel wrote: On Sunday, 7 April 2019 at 17:16:12 UTC, Seb wrote: --- ["a": 1].byPair.array.sort!((a, b) => a.value < a.value).release.each!writeln; --- What's the purpose of .release? The documentation in

Re: I really don't understand DUB

2019-04-08 Thread Dennis via Digitalmars-d-learn
On Monday, 8 April 2019 at 19:54:28 UTC, WhatMeWorry wrote: Now, I've studied the on-line documentation and even walked through the code somewhat but I'm not making an headway. Very relatable. My tips so far are: - Look for projects in github with a similar structure to yours and look at

Re: How to compile and link simple application?

2019-04-08 Thread Julian via Digitalmars-d-learn
On Monday, 8 April 2019 at 19:43:11 UTC, Julian wrote: On Monday, 8 April 2019 at 19:29:33 UTC, 4544fa8d wrote: It's really not possible to call functions in modules like in any other languages? :S What some other languages do is collect all of those calls into an implicit function that's

const of AliasSeq is silently ignored

2019-04-08 Thread Yuxuan Shui via Digitalmars-d-learn
In this example: const(AliasSeq!(int, int)) a; pragma(msg, typeof(a)); // (int, int) This kind of make sense, since AliasSeq is not a "single" type. But silently dropping const seems bad, the compiler should probably report an error/warning in this case?

I really don't understand DUB

2019-04-08 Thread WhatMeWorry via Digitalmars-d-learn
I've been using DUB for several years and I've gotten it to work generally. But I've been trying to troubleshoot a DUB issue for two days now and I've come to the conclusion, I don't really understand DUB and I'm tired of muddling through. (Surely it hurts that I've never been exposed to a

Re: Iterate/sort associative array by value?

2019-04-08 Thread Dennis via Digitalmars-d-learn
On Monday, 8 April 2019 at 18:04:28 UTC, kdevel wrote: What's the purpose of .release? The documentation in https://dlang.org/phobos/std_range.html#.SortedRange.release is rather monosyllabic. The sort function returns a SortedRange, which is usually an array wrapper with the extra type

Re: How to compile and link simple application?

2019-04-08 Thread Julian via Digitalmars-d-learn
On Monday, 8 April 2019 at 19:29:33 UTC, 4544fa8d wrote: It's really not possible to call functions in modules like in any other languages? :S What some other languages do is collect all of those calls into an implicit function that's called before main(). What D does is run that code at

Re: How to compile and link simple application?

2019-04-08 Thread 4544fa8d via Digitalmars-d-learn
On Monday, 8 April 2019 at 19:05:33 UTC, Julian wrote: Shorter: string root_dir() { static string cache; return cache ? cache : (cache = dirName(thisExePath())); } This might spam readlink() syscalls if they somehow return the It's really not possible to call functions in

Re: How to compile and link simple application?

2019-04-08 Thread Julian via Digitalmars-d-learn
On Monday, 8 April 2019 at 18:54:10 UTC, Julian wrote: @property string root_dir() { static string cache; static bool isInit = false; if (!isInit) { isInit = true; cache = dirName(thisExePath()); } return cache; } Shorter: string

Re: How to compile and link simple application?

2019-04-08 Thread Julian via Digitalmars-d-learn
On Monday, 8 April 2019 at 18:47:42 UTC, 4544fa8d wrote: On Monday, 8 April 2019 at 18:41:00 UTC, Adam D. Ruppe wrote: Did you put your code inside a main() function? I want to make constant with path to directory containing executable. This line is above main():

Re: How to compile and link simple application?

2019-04-08 Thread Julian via Digitalmars-d-learn
On Monday, 8 April 2019 at 18:38:58 UTC, 4544fa8d wrote: Hello, I have "hello world" application. I imported std.file, executed thisExePath() and now I have this error: dmd -m64 -of=../../bin/manager -release ./src/manager.d

Re: How to compile and link simple application?

2019-04-08 Thread 4544fa8d via Digitalmars-d-learn
On Monday, 8 April 2019 at 18:41:00 UTC, Adam D. Ruppe wrote: Did you put your code inside a main() function? I want to make constant with path to directory containing executable. This line is above main(): - const ROOT_DIR = dirName(thisExePath());

Re: How to compile and link simple application?

2019-04-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 8 April 2019 at 18:38:58 UTC, 4544fa8d wrote: Whats going on? Why I cant build my executable file? Did you put your code inside a main() function?

How to compile and link simple application?

2019-04-08 Thread 4544fa8d via Digitalmars-d-learn
Hello, I have "hello world" application. I imported std.file, executed thisExePath() and now I have this error: dmd -m64 -of=../../bin/manager -release ./src/manager.d /usr/include/dmd/phobos/std/file.d(3252): Error: readlink

Re: Iterate/sort associative array by value?

2019-04-08 Thread Julian via Digitalmars-d-learn
On Monday, 8 April 2019 at 17:13:32 UTC, Seb wrote: On Monday, 8 April 2019 at 08:31:33 UTC, Dennis wrote: On Monday, 8 April 2019 at 07:53:23 UTC, Robert M. Münch wrote: Why does DMD not give a hint, that an import from the standard lib might be missing? I find these explicit import

Re: Iterate/sort associative array by value?

2019-04-08 Thread kdevel via Digitalmars-d-learn
On Sunday, 7 April 2019 at 17:16:12 UTC, Seb wrote: --- ["a": 1].byPair.array.sort!((a, b) => a.value < a.value).release.each!writeln; --- What's the purpose of .release? The documentation in https://dlang.org/phobos/std_range.html#.SortedRange.release is rather monosyllabic.

Re: Iterate/sort associative array by value?

2019-04-08 Thread Seb via Digitalmars-d-learn
On Monday, 8 April 2019 at 08:31:33 UTC, Dennis wrote: On Monday, 8 April 2019 at 07:53:23 UTC, Robert M. Münch wrote: Why does DMD not give a hint, that an import from the standard lib might be missing? I find these explicit import statements very annyoing. There currently are a few

Re: Templates - What's Up with the template keyword?

2019-04-08 Thread Ron Tarrant via Digitalmars-d-learn
On Monday, 8 April 2019 at 14:56:46 UTC, Mike Parker wrote: In the subsequent sections, I show both long and short (eponymous) forms of enum and function templates. Forgot to say... I'm typing in the examples as I go and so far I haven't been lost. Even when you don't come right out and say

Re: Templates - What's Up with the template keyword?

2019-04-08 Thread Ron Tarrant via Digitalmars-d-learn
On Monday, 8 April 2019 at 14:56:46 UTC, Mike Parker wrote: You should have read further along in that chapter :-) LOL! Actually, after reading Adam's reply, I dug back into your book and I'm starting to get a reasonable handle on this. I must say, I like the slow-but-steady intro you

Re: Templates - What's Up with the template keyword?

2019-04-08 Thread Mike Parker via Digitalmars-d-learn
On Monday, 8 April 2019 at 12:23:28 UTC, Ron Tarrant wrote: First, the question... In Michael Parker's book, "Learning D," (Packt, 2015) on page 160 he gives an example of a basic template: template MyTemplate(T) { T val; void printVal() { import std.stdio : writeln;

Re: Cannot link vibe.d sample / optlink error

2019-04-08 Thread Radu via Digitalmars-d-learn
On Monday, 8 April 2019 at 13:42:31 UTC, Michal Minich wrote: I used dmd 2.085.0 and 2.085.1 on Win 10 I followed sample at https://vibed.org/blog/posts/a-scalable-chat-room-service-in-d Just the beginning, where you you should compile hello word web app. command line: "dub" compilation

Re: Overloads not returning appropriate info. [Field reflunkory]

2019-04-08 Thread Alex via Digitalmars-d-learn
On Monday, 8 April 2019 at 12:26:28 UTC, Adam D. Ruppe wrote: On Sunday, 7 April 2019 at 17:42:58 UTC, Alex wrote: That is blatantly wrong. The code works EXACTLY the same way with and without using stringof. In some cases, yeah. In the general case, no. Your import hack* is only there

Re: What Does @ Mean?

2019-04-08 Thread Ron Tarrant via Digitalmars-d-learn
On Monday, 8 April 2019 at 14:27:11 UTC, JN wrote: Java uses @ for annotations too. Pascal uses @ for "address of", like & in D. Just one of the many reasons I balked at Java... many MANY reasons. Thanks, JN.

Re: What Does @ Mean?

2019-04-08 Thread Ron Tarrant via Digitalmars-d-learn
On Monday, 8 April 2019 at 14:19:04 UTC, XavierAP wrote: On Monday, 8 April 2019 at 11:58:49 UTC, Ron Tarrant wrote: And while I'm asking, does an underscore have special meaning when used either at the beginning or end of a variable name? In D, @ is used as Adam has explained as a prefix

Re: What Does @ Mean?

2019-04-08 Thread JN via Digitalmars-d-learn
On Monday, 8 April 2019 at 14:19:04 UTC, XavierAP wrote: The only other example of language using @, in an almost but not quite completely different way, is C#. It's also a prefix that allows you to define names that would collide with reserved words, for example string @class = "menu"; Of

Re: What Does @ Mean?

2019-04-08 Thread XavierAP via Digitalmars-d-learn
On Monday, 8 April 2019 at 11:58:49 UTC, Ron Tarrant wrote: And while I'm asking, does an underscore have special meaning when used either at the beginning or end of a variable name? In D, @ is used as Adam has explained as a prefix indicating attributes (either user-defined ones or,

Re: Iterate/sort associative array by value?

2019-04-08 Thread diniz via Digitalmars-d-learn
Le 07/04/2019 à 19:16, Seb via Digitalmars-d-learn a écrit : Then you can do: --- ["a": 1].byPair.array.sort!((a, b) => a.value < a.value).release.each!writeln; --- You'll have a sorted array with key and value props. That's what I would do: just operating on an array of {k,v} pairs. --

Cannot link vibe.d sample / optlink error

2019-04-08 Thread Michal Minich via Digitalmars-d-learn
I used dmd 2.085.0 and 2.085.1 on Win 10 I followed sample at https://vibed.org/blog/posts/a-scalable-chat-room-service-in-d Just the beginning, where you you should compile hello word web app. command line: "dub" compilation finishes ok. then it prints "Linking..." and I get window

Re: Templates - What's Up with the template keyword?

2019-04-08 Thread Ron Tarrant via Digitalmars-d-learn
On Monday, 8 April 2019 at 12:40:10 UTC, Adam D. Ruppe wrote: You don't need template keyword for the majority of cases because the compiler lets you do shortcuts. Thanks, Adam. Good to know. (maybe I am looking at the wrong part of the book, it is hard to find the right section/page number

Re: What Does @ Mean?

2019-04-08 Thread Ron Tarrant via Digitalmars-d-learn
Well, that was quick! Thanks Adam, Kagamin, and Alex.

Re: Templates - What's Up with the template keyword?

2019-04-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 8 April 2019 at 12:23:28 UTC, Ron Tarrant wrote: But in "Programming in D," (self, 2009-2018) by Ali Çehreli, there's no mention of the 'template' keyword in any of his examples. You don't need template keyword for the majority of cases because the compiler lets you do shortcuts.

Re: Overloads not returning appropriate info. [Field reflunkory]

2019-04-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 7 April 2019 at 17:42:58 UTC, Alex wrote: That is blatantly wrong. The code works EXACTLY the same way with and without using stringof. In some cases, yeah. In the general case, no. Your import hack* is only there because of stringof. Using the local symbol, there is no need to

Templates - What's Up with the template keyword?

2019-04-08 Thread Ron Tarrant via Digitalmars-d-learn
I'm digging into templates in an attempt to understand the signals-n-slots replacement for the observer pattern, but I've got a question I can't seem to find an answer for and an example for which I'm unable to solve the error. First, the question... In Michael Parker's book, "Learning D,"

Re: What Does @ Mean?

2019-04-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 8 April 2019 at 11:58:49 UTC, Ron Tarrant wrote: Would someone please tell me what an at sign (@) means when it's used like this: bool isLeaf() @property In that case, it means nothing. We just defined the word to be `@property`, with the @ included. So it is just part of the

Re: Pass template parameter into q{} string

2019-04-08 Thread Kagamin via Digitalmars-d-learn
Maybe just use mixin template? mixin template f(alias values) { static foreach(v;values) mixin("bool " ~ v ~ " = false;"); } int main() { enum string[] a=["a","b"]; mixin f!a; return 0; }

Re: What Does @ Mean?

2019-04-08 Thread Kagamin via Digitalmars-d-learn
https://dlang.org/spec/function.html#property-functions

Re: What Does @ Mean?

2019-04-08 Thread Alex via Digitalmars-d-learn
On Monday, 8 April 2019 at 11:58:49 UTC, Ron Tarrant wrote: This is frustrating and makes me feel like a complete newb. Worse, it's impossible to search for. Ever try Googling a single character? The D documentation also doesn't seem to explain the meaning of this or any other token. Sure,

Re: D threading and shared variables

2019-04-08 Thread Kagamin via Digitalmars-d-learn
On Sunday, 7 April 2019 at 14:49:20 UTC, Archie Allison wrote: The codebase is a reasonable size so too big (and proprietary) to share. You can reduce it to a minimal example that doesn't work. Static variables are thread local by default in D unless they are marked as shared or __gshared.

What Does @ Mean?

2019-04-08 Thread Ron Tarrant via Digitalmars-d-learn
This is frustrating and makes me feel like a complete newb. Worse, it's impossible to search for. Ever try Googling a single character? The D documentation also doesn't seem to explain the meaning of this or any other token. Sure, most of them are obvious, but this one eludes me. All I can

Re: Iterate/sort associative array by value?

2019-04-08 Thread Dennis via Digitalmars-d-learn
On Monday, 8 April 2019 at 07:53:23 UTC, Robert M. Münch wrote: Why does DMD not give a hint, that an import from the standard lib might be missing? I find these explicit import statements very annyoing. There currently are a few hard-coded import hints for common functions:

Re: Iterate/sort associative array by value?

2019-04-08 Thread Julian via Digitalmars-d-learn
On Monday, 8 April 2019 at 07:53:23 UTC, Robert M. Münch wrote: On 2019-04-07 19:28:02 +, Dennis said: Did you import it? import std.algorithm; :-/ of course not... Why does DMD not give a hint, that an import from the standard lib might be missing? It does do this, so the question

Re: Iterate/sort associative array by value?

2019-04-08 Thread Robert M. Münch via Digitalmars-d-learn
On 2019-04-07 19:28:02 +, Dennis said: Did you import it? import std.algorithm; :-/ of course not... Why does DMD not give a hint, that an import from the standard lib might be missing? I find these explicit import statements very annyoing. DMD should build up a database of stuff it