Re: cannot access frame of function

2017-09-18 Thread user1234 via Digitalmars-d-learn
On Monday, 18 September 2017 at 14:45:25 UTC, Alex wrote: Hi all, given this code: import std.algorithm.iteration : sum, cumulativeFold; void main() { double[5] a; a = 0; foreach(el; a) assert(el == 0); a[0] = 1.0; a[1] = 2.0; a[2] = 3.0;

Re: cannot access frame of function

2017-09-18 Thread user1234 via Digitalmars-d-learn
On Monday, 18 September 2017 at 18:49:54 UTC, ag0aep6g wrote: On 09/18/2017 08:25 PM, user1234 wrote: On Monday, 18 September 2017 at 14:45:25 UTC, Alex wrote: [...] import std.algorithm.iteration : sum, cumulativeFold; void main() { double[5] a; [...]>> auto asum = a[].sum; [...]

Re: Problems with function as parameter

2017-09-22 Thread user1234 via Digitalmars-d-learn
On Friday, 22 September 2017 at 04:32:08 UTC, Josh wrote: As an aside, in that doc it says "The .funcptr property of a delegate will return the function pointer value as a function type". So I also tried Mix_ChannelFinished(().funcptr); and this compiled, but caused a segfault when the

Re: Why isn't there more if(__ctfe) in std.math ?

2017-09-23 Thread user1234 via Digitalmars-d-learn
On Saturday, 23 September 2017 at 18:23:12 UTC, Juraj Mojzis wrote: Hi, browsing trough phobos bugzilla I found a couple of open issues regarding CTFE and basic math functions ( Issue 4177, 5227). It looks to me that at least floor/ceil could by fixed by a simple: if (__ctfe) return

Re: Add a precompiled c++ obj file to dub

2017-10-07 Thread user1234 via Digitalmars-d-learn
On Saturday, 7 October 2017 at 19:56:52 UTC, Fra Mecca wrote: Hi all, I am writing a backend that is partly Vibe.d and partly clucene in c++. I have some object files written in c++ and compiled with g++ that are not considered by dub during the linking phase and throws `function undefined

Re: Add a precompiled c++ obj file to dub

2017-10-07 Thread user1234 via Digitalmars-d-learn
On Sunday, 8 October 2017 at 02:58:36 UTC, Fra Mecca wrote: On Saturday, 7 October 2017 at 23:54:50 UTC, user1234 wrote: On Saturday, 7 October 2017 at 19:56:52 UTC, Fra Mecca wrote: Hi all, I am writing a backend that is partly Vibe.d and partly clucene in c++. I have some object files

Re: Assert and undefined behavior

2017-10-11 Thread user1234 via Digitalmars-d-learn
On Wednesday, 11 October 2017 at 09:27:49 UTC, John Burton wrote: [...] I therefore feel like I ought to not use assert and should instead validate my assumptions with an if statement and a throw or exit or something. Yes, that's the way of doing. assert() are just used to test the program.

Re: Performance Issue

2017-09-06 Thread user1234 via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 09:44:09 UTC, Vino.B wrote: Hi, The below code is consume more memory and slower can you provide your suggestion on how to over come these issues. string[][] csizeDirList (string FFs, int SizeDir) { ulong subdirTotal = 0; ulong subdirTotalGB;

Re: dispatcher

2017-09-06 Thread user1234 via Digitalmars-d-learn
On Wednesday, 6 September 2017 at 05:57:18 UTC, Psychological Cleanup wrote: I have a C callback that must call some functions declared in D. I can't call them off the C thread because it will result in a violation. What is a good way to dispatch the call to the main D program? I'm thinking

Re: Struct with float members in betterC

2017-09-05 Thread user1234 via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 11:58:18 UTC, Azi Hassan wrote: Hi, I'm trying to create the following struct in betterC but I keep getting undefined reference errors when I try to compile the code : [...] I'm aware that betterC is still experimental at this point, but I thought I'd ask

Re: Why does BinaryHeap sometime cause compile-error in foeach?

2017-09-30 Thread user1234 via Digitalmars-d-learn
On Saturday, 30 September 2017 at 09:27:23 UTC, Shigeki Karita wrote: https://dpaste.dzfl.pl/cd605899d050 why this code cannot convert to foreach (over Structs and Classes with Ranges). auto h = new BinaryHeap!(int[])(new int[0]); typeof(h).stringof.writeln; static

Re: generating @property from structs

2017-09-30 Thread user1234 via Digitalmars-d-learn
On Saturday, 30 September 2017 at 08:20:44 UTC, Nicholas Wilson wrote: struct MyType { void* ptr; static struct Info { @(42) int foo; } // Should be generated by the mixin below @property int foo() { int ret;

Re: static this not run?

2017-09-30 Thread user1234 via Digitalmars-d-learn
On Saturday, 30 September 2017 at 06:15:41 UTC, Nicholas Wilson wrote: No "initialising onError", the static this is not even being run! I'm using LDC master. See also https://github.com/libmir/dcompute/issues/32 LDC 1.4, DMD 2.076, DMD ~master and finally GDC all give the expected result

Re: Is it possible to specify the address returned by the address of operator?

2017-09-27 Thread user1234 via Digitalmars-d-learn
On Wednesday, 27 September 2017 at 21:01:36 UTC, Jesse Phillips wrote: On Wednesday, 27 September 2017 at 16:35:54 UTC, DreadKyller wrote: My question is about overloading, several operators can be overloaded in D, one of the ones that can't apparently is the address of operator (). My

Re: Is it possible to specify the address returned by the address of operator?

2017-09-28 Thread user1234 via Digitalmars-d-learn
On Thursday, 28 September 2017 at 00:11:56 UTC, DreadKyller wrote: On Wednesday, 27 September 2017 at 23:24:58 UTC, user1234 wrote: Notice how dereferencing the pointer did not call the overloaded function, because a pointer to Test is not the same type as a Test. Yeah, this is rather made

Re: 2 Dimensional Array Sorting

2017-08-26 Thread user1234 via Digitalmars-d-learn
On Saturday, 26 August 2017 at 06:11:37 UTC, user1234 wrote: On Saturday, 26 August 2017 at 06:01:15 UTC, Vino.B wrote: Hi, Can someone provide me a example of sorting 2 Dimensional Array containing Filename and Size, and should be sorted by Size. From, Vino.B void main(string[] args) {

Re: 2 Dimensional Array Sorting

2017-08-26 Thread user1234 via Digitalmars-d-learn
On Saturday, 26 August 2017 at 06:01:15 UTC, Vino.B wrote: Hi, Can someone provide me a example of sorting 2 Dimensional Array containing Filename and Size, and should be sorted by Size. From, Vino.B void main(string[] args) { import std.stdio; import std.algorithm.sorting;

Re: pipeProcess not returning immediately

2017-08-26 Thread user1234 via Digitalmars-d-learn
On Saturday, 26 August 2017 at 01:13:35 UTC, Johnson Jones wrote: I am running ffplay.exe and my application does not return immediately from pipeProcess. I have to close ffplay for my program to continue execution. No process is asynchronous in std.process. If you don't want to block your

Re: testing for deprecation

2017-08-26 Thread user1234 via Digitalmars-d-learn
On Friday, 25 August 2017 at 20:35:52 UTC, jmh530 wrote: On Thursday, 1 September 2016 at 11:13:42 UTC, rikki cattermole wrote: That is a first that somebody wanted it. Bug report please! I just ran across this with deprecated { void foo(); } void main() { pragma(msg,

Re: 2 Dimensional Array Sorting

2017-08-26 Thread user1234 via Digitalmars-d-learn
On Saturday, 26 August 2017 at 09:53:44 UTC, Vino.B wrote: On Saturday, 26 August 2017 at 06:12:57 UTC, user1234 wrote: [...] Hi, I tired you logic, but doesn't seem to be working, as every time i execute the order of the file list is different as in the below program i have used the sort

Re: testing for deprecation

2017-08-29 Thread user1234 via Digitalmars-d-learn
On Tuesday, 29 August 2017 at 05:03:39 UTC, Sebastien Alaiwan wrote: On Thursday, 1 September 2016 at 11:11:15 UTC, Cauterite wrote: How does one test whether a symbol is deprecated? I would have expected something like: __traits(isDeprecated, foo). Such a trait makes it possible to write

Re: Template substitution for function parameters

2017-09-01 Thread user1234 via Digitalmars-d-learn
On Friday, 1 September 2017 at 10:15:09 UTC, Nicholas Wilson wrote: So I have the following types ... i.e. it substitutes the template DevicePointer for the template Buffer in Parameters!foo, The templates can be assumed to not be nested templates, i.e. DevicePointer!(DevicePointer!(float))

Re: readln of german Umlaute (terminal.d) / readln)

2017-10-17 Thread user1234 via Digitalmars-d-learn
On Tuesday, 17 October 2017 at 15:02:29 UTC, Adam D. Ruppe wrote: Or try this newest commit https://github.com/adamdruppe/arsd/blob/master/terminal.d and see if it works better for you. in the commit message: ~~ascii~~ ANSI.

Re: testing if data is allocated on the stack or heap

2017-10-17 Thread user1234 via Digitalmars-d-learn
On Tuesday, 17 October 2017 at 17:27:17 UTC, Biotronic wrote: On Tuesday, 17 October 2017 at 15:33:02 UTC, drug wrote: [...] I have very little knowledge about sbrk, so here's my solution. Tested on win32 and win64. [...] Nice solution. Is `stackStart` thread local on purpose?

Re: Trait to identify if a type is a struct one

2017-10-18 Thread user1234 via Digitalmars-d-learn
On Wednesday, 18 October 2017 at 15:16:21 UTC, drug wrote: 18.10.2017 18:11, pham пишет: Is there a way to identify if a type is a struct, something like isStruct similar to isArray. struct X { } isStruct!X == true? Also, there are isAbstractClass & isFinalClass but want to check if type

Re: Strange error when compiling with dmd, not with ldc

2017-11-29 Thread user1234 via Digitalmars-d-learn
On Wednesday, 29 November 2017 at 06:18:09 UTC, Fra Mecca wrote: I have this struct: immutable struct Configuration { string title; string baseurl; string url; string email; string author; string parser; string target; string urlFormat; string urlFormatCmd;

Re: Strange error when compiling with dmd, not with ldc

2017-11-29 Thread user1234 via Digitalmars-d-learn
On Wednesday, 29 November 2017 at 10:55:35 UTC, user1234 wrote: On Wednesday, 29 November 2017 at 06:18:09 UTC, Fra Mecca wrote: [...] You must also use a type constructor later, when a Configuration is declared: ``` immutable(Configuration) config; config.toString.writeln; // okay this

Re: Basic questions about D lang?

2017-11-29 Thread user1234 via Digitalmars-d-learn
On Wednesday, 29 November 2017 at 11:32:51 UTC, Jayam wrote: In D lang, [...] 3. Can we make library file and use that in any project like 'Util class' ? Of course ! Plenty of them can be found here: https://code.dlang.org/?sort=updated=library

Re: Template specialisation, "Generic type locking", offline stdlib docs and case-based template question

2017-11-30 Thread user1234 via Digitalmars-d-learn
On Friday, 1 December 2017 at 03:39:12 UTC, helxi wrote: 1. Template specialisation. Why is this useful?: T getResponse(T = int)(string question); And how does it differ from int getResponse(string question); ? Good Q. Without thinking more it looks like a pointless example. The only

Re: On Attributes

2017-11-27 Thread user1234 via Digitalmars-d-learn
On Monday, 27 November 2017 at 20:07:08 UTC, A Guy With a Question wrote: On Monday, 27 November 2017 at 19:41:03 UTC, Adam D. Ruppe wrote: On Monday, 27 November 2017 at 19:10:04 UTC, A Guy With a One thing that is bugging me is having to mark up all of my declarations with attributes. Meh,

Re: convert string to ubyte[]

2017-11-11 Thread user1234 via Digitalmars-d-learn
On Saturday, 11 November 2017 at 15:48:59 UTC, Mike Parker wrote: On Saturday, 11 November 2017 at 15:38:18 UTC, aki wrote: auto bytes = cast(immutable(ubyte)[])s; Of course, if you need a mutable array you should dup: auto bytes = cast(ubyte[])s.dup; Not only "should" but he "must"

Strange AV in asm mode (code only for amd64)

2017-11-05 Thread user1234 via Digitalmars-d-learn
Hello, try this: --- import std.stdio; alias Proc = size_t function(); size_t allInnOne() { asm pure nothrow { mov RAX, 1; ret; nop;nop;nop;nop;nop;nop;nop; mov RAX, 2; ret; } } void main() { Proc proc1 = Proc proc2 = cast(Proc)

Re: Strange AV in asm mode (code only for amd64)

2017-11-05 Thread user1234 via Digitalmars-d-learn
On Sunday, 5 November 2017 at 14:27:18 UTC, Eugene Wissner wrote: On Sunday, 5 November 2017 at 13:43:15 UTC, user1234 wrote: [...] One of the problems is that "naked" is missing in your assembly. If you write asm pure nothrow { naked; mov RAX, 1; ret;

Re: Strange AV in asm mode (code only for amd64)

2017-11-05 Thread user1234 via Digitalmars-d-learn
On Sunday, 5 November 2017 at 13:43:15 UTC, user1234 wrote: [...] Hmmm it was just the amount of nops. --- import std.stdio; alias Proc = size_t function(); size_t allInnOne() { asm pure nothrow { naked; mov RAX, 1; ret; nop;nop; mov RAX, 2;

Re: Strange AV in asm mode (code only for amd64)

2017-11-06 Thread user1234 via Digitalmars-d-learn
On Sunday, 5 November 2017 at 14:25:24 UTC, user1234 wrote: On Sunday, 5 November 2017 at 13:43:15 UTC, user1234 wrote: [...] Hmmm it was just the amount of nops. --- import std.stdio; alias Proc = size_t function(); size_t allInnOne() { asm pure nothrow { naked;

Re: Does dmd not always compile all of the source code?

2017-12-07 Thread user1234 via Digitalmars-d-learn
On Wednesday, 6 December 2017 at 19:19:09 UTC, A Guy With a Question wrote: On Wednesday, 6 December 2017 at 18:09:45 UTC, Steven Schveighoffer wrote: On 12/6/17 12:17 PM, Steven Schveighoffer wrote: So why wouldn't the compiler fail? Because it has no idea yet what you mean by Nullable. It

Re: Sort in return statement

2017-12-08 Thread user1234 via Digitalmars-d-learn
On Saturday, 9 December 2017 at 03:24:52 UTC, codephantom wrote: On Saturday, 9 December 2017 at 02:45:35 UTC, rjframe wrote: `sort` returns a SortedRange of ushorts, not an array of ushorts. Make it: ``` import std.array : array; return sort(numbers.take(8)).array; ``` --Ryan That's it!

Re: Debugging shared libs on windows

2017-12-06 Thread user1234 via Digitalmars-d-learn
On Wednesday, 6 December 2017 at 21:17:55 UTC, Tofu ninja wrote: On Wednesday, 6 December 2017 at 21:12:20 UTC, Tofu ninja wrote: I am compiling with -m64 -shared -debug -g and a .pdb is generated but visual studio says the dll was not compiled with debug information, am I missing something or

Re: DMD Callstacks

2017-10-24 Thread user1234 via Digitalmars-d-learn
On Tuesday, 24 October 2017 at 06:49:37 UTC, abad wrote: On Monday, 23 October 2017 at 12:41:09 UTC, Márcio Martins wrote: What is everyone doing to get proper file name and line number info for callstacks with DMD? addr2line just gives me ??:0 You could try compiling with the

Re: is(this : myClass)

2017-10-20 Thread user1234 via Digitalmars-d-learn
On Friday, 20 October 2017 at 21:42:32 UTC, Jonathan M Davis wrote: On Friday, October 20, 2017 21:32:48 Patrick via Digitalmars-d-learn wrote: The compiler seems to reject the following code in a class method: bool test = is(this : myClass); Could some please explain this? "this" is not a

Re: Is it feasible to slowly rewrite a C++ codebase in D?

2018-06-20 Thread user1234 via Digitalmars-d-learn
On Wednesday, 20 June 2018 at 18:47:10 UTC, Jordi Gutiérrez Hermoso wrote: I'm specifically thinking of the GNU Octave codebase: http://hg.savannah.gnu.org/hgweb/octave/file/@ It's a fairly old and complicated C++ codebase. I would like to see if I could slowly introduce some D in it,

Re: Ambiguous template parameter names

2018-05-02 Thread user1234 via Digitalmars-d-learn
On Wednesday, 2 May 2018 at 20:32:43 UTC, jmh530 wrote: In the function below, there is a template parameter and a normal parameter both with the same name. However, the function returns the normal parameter. The template parameter is effectively ignored. I was surprised by this behavior. Is

Re: How to find the content of core.sys.* ?

2017-10-28 Thread user1234 via Digitalmars-d-learn
On Saturday, 28 October 2017 at 11:41:16 UTC, Ryan Frame wrote: On Tuesday, 17 May 2016 at 06:56:36 UTC, rikki cattermole wrote: On 17/05/2016 6:55 PM, chmike wrote: Hello, The nice and handy documentation of dlang doesn't provide any info on the core.sys. How can I find out all the things

Re: What could this OptLink Error mean?

2017-12-29 Thread user1234 via Digitalmars-d-learn
On Friday, 29 December 2017 at 16:11:20 UTC, Dukc wrote: I was building one example of DLangUi (dub build --build-mode=allAtOnce --build=debuglinker) and it did compile but the linker started to complain. I did notice it seemed to be related to the standard library, so I updated it and

Re: Don't expect class destructors to be called at all by the GC

2017-12-20 Thread user1234 via Digitalmars-d-learn
On Thursday, 21 December 2017 at 02:57:00 UTC, Mike Franklin wrote: "Don't expect class destructors to be called at all by the GC" I was a bit shocked to read that here: https://p0nce.github.io/d-idioms/#The-trouble-with-class-destructors The document tries to clarify with: "The garbage

Re: Help optimizing code?

2018-01-01 Thread user1234 via Digitalmars-d-learn
On Monday, 1 January 2018 at 15:09:53 UTC, Lily wrote: I started learning D a few days ago, coming from some very basic C++ knowledge, and I'd like some help getting a program to run faster. The code is here: https://github.com/IndigoLily/D-mandelbrot/blob/master/mandelbrot.d Right now it

Re: Help optimizing code?

2018-01-01 Thread user1234 via Digitalmars-d-learn
On Monday, 1 January 2018 at 15:23:19 UTC, Adam D. Ruppe wrote: On Monday, 1 January 2018 at 15:09:53 UTC, Lily wrote: I started learning D a few days ago, coming from some very basic C++ knowledge, and I'd like some help getting a program to run faster. So a few easy things you can do: 1)

Re: How do you check for nonempty string?

2018-04-13 Thread user1234 via Digitalmars-d-learn
On Friday, 13 April 2018 at 17:41:00 UTC, Adam D. Ruppe wrote: On Friday, 13 April 2018 at 17:38:39 UTC, Dr.No wrote: string s = null; if(s !is null && s[0] == '/') is this correct? No, that doesn't work if the string = "a"[$..$] for example Just use if(s.length && s[0]) instead just

Re: Program exited with code 1

2018-04-19 Thread user1234 via Digitalmars-d-learn
On Thursday, 19 April 2018 at 08:13:00 UTC, Andrey wrote: Hello, I wrote a small test code with WinApi: import core.runtime; import std.utf; import core.sys.windows.windows; import core.sys.windows.wingdi; class Test { public this()

Re: Help with Regular Expressions (std.regex)

2019-03-03 Thread user1234 via Digitalmars-d-learn
On Sunday, 3 March 2019 at 18:07:57 UTC, Samir wrote: I am belatedly working my way through the 2018 edition of the Advent of Code[1] programming challenges using D and am stumped on Problem 3[2]. The challenge requires you to parse a set of lines in the format: #99 @ 652,39: 24x23 #100 @

Re: Help with Regular Expressions (std.regex)

2019-03-03 Thread user1234 via Digitalmars-d-learn
On Sunday, 3 March 2019 at 18:32:14 UTC, user1234 wrote: On Sunday, 3 March 2019 at 18:07:57 UTC, Samir wrote: or // sorry i don't have the regex API in mind import std.array: array; import std.alogrithm.iteration : map; auto allMatches = matchAll(line, pattern).map(a => a.hit).array;

Re: Is there any performance penalty for static if?

2019-05-15 Thread user1234 via Digitalmars-d-learn
On Wednesday, 15 May 2019 at 22:03:39 UTC, Ferhat Kurtulmuş wrote: Hi, Maybe I already know the answer, but have to be sure about this. I am emulating this cpp code "int val = mat.at(row, col)" like: T at(T)(int row, int col){ static if (T.stringof == "float"){ return

Re: Delegate / Error: cannot implicitly convert expression...

2019-06-15 Thread user1234 via Digitalmars-d-learn
On Saturday, 15 June 2019 at 16:34:22 UTC, Robert M. Münch wrote: On 2019-06-15 16:19:23 +, Anonymouse said: By design, I think: "delegate and function objects cannot be mixed. But the standard function std.functional.toDelegate converts a function to a delegate." Your example compiles

Re: Delegate / Error: cannot implicitly convert expression...

2019-06-15 Thread user1234 via Digitalmars-d-learn
On Saturday, 15 June 2019 at 17:42:04 UTC, ag0aep6g wrote: On Saturday, 15 June 2019 at 17:24:45 UTC, user1234 wrote: --- void foo(){writeln(__PRETTY_FUNCTION__);} void main(string[] args) { void delegate() dg; dg.funcptr = dg.ptr = null; // usually a "this" or a frame address

Re: CT/RT annoyance

2019-06-17 Thread user1234--- via Digitalmars-d-learn
On Monday, 17 June 2019 at 05:04:50 UTC, Bart wrote: Consider void foo(string A = "")(string B = "") { static if (A != "") do(A); else do(B); } [...] I see the annoyance but D clearly separates what is CT and RT so such a change would require a DIP. I don't even know

Re: Order of interfaces

2019-06-21 Thread user1234 via Digitalmars-d-learn
On Friday, 21 June 2019 at 20:42:00 UTC, Tomas wrote: Does it matter in which order a class inherits from interfaces? class A : Interface1, Interface2{ ... } vs class A : Interface2, Interface1{ ... } Conceptually it should not matter, but I'm getting really weird segfault errors

Re: Nothing at all compiles with -m64 on Windows

2019-05-11 Thread user1234 via Digitalmars-d-learn
On Saturday, 11 May 2019 at 09:59:25 UTC, Anonymouse wrote: On Tuesday, 7 May 2019 at 17:33:22 UTC, Ron Tarrant wrote: I've had this happen, too. I don't know for sure, but I think it may be because the installers aren't prepared to do updates, not on Windows, anyway. My best success for

Re: Static struct?

2019-04-24 Thread user1234 via Digitalmars-d-learn
On Wednesday, 24 April 2019 at 21:12:10 UTC, JN wrote: I noticed a construct I haven't seen before in D when reading the description for automem - https://github.com/atilaneves/automem static struct Point { int x; int y; } What does "static" do in this case? How does it

Re: Is this a new bug ?

2019-07-20 Thread user1234 via Digitalmars-d-learn
On Saturday, 20 July 2019 at 05:21:01 UTC, Newbie2019 wrote: On Saturday, 20 July 2019 at 04:18:15 UTC, Adam D. Ruppe wrote: show me what you're doing now and I'll see which case it is. Most the time I see these, the code is significantly simplified and bugs fixed by removing the usages of

Re: Why same pointer type for GC and manual memory?

2019-11-15 Thread user1234 via Digitalmars-d-learn
On Wednesday, 13 November 2019 at 11:07:12 UTC, IGotD- wrote: I'm trying to find the rationale why GC pointers (should be names managed pointers) are using the exact same type as any other pointer. Doesn't this limit the ability to change the default GC type? Doesn't this confusion make GC

Re: std.container.array: Error: unable to determine fields of Test because of forward references

2019-10-31 Thread user1234 via Digitalmars-d-learn
On Thursday, 31 October 2019 at 12:29:28 UTC, Tobias Pankrath wrote: My Problem: --- (https://run.dlang.io/is/CfLscj) import std.container.array; import std.traits; struct Test { Test[] t; } struct Test2 { Array!Test2 t; } int main() { return FieldTypeTuple!Test.length +

Re: std.container.array: Error: unable to determine fields of Test because of forward references

2019-10-31 Thread user1234 via Digitalmars-d-learn
On Thursday, 31 October 2019 at 12:37:55 UTC, user1234 wrote: On Thursday, 31 October 2019 at 12:29:28 UTC, Tobias Pankrath wrote: [...] Try struct S { S*[] children; } because otherwise when you declare the array the compiler has not finished the semantic ana of S. so S size is not

Re: Some impressions/notes from a new D programmer

2020-02-12 Thread user1234 via Digitalmars-d-learn
On Wednesday, 12 February 2020 at 15:28:57 UTC, Anonymouse wrote: Maybe there are some hard design decisions again $HOME/.dub/bin, unsure. It might be difficult to globally pull off if programs expect the binary to be placed in the source tree (for resources). [1]:

Re: Type sequence concatenation / associative array implementation

2020-02-12 Thread user1234 via Digitalmars-d-learn
On Wednesday, 12 February 2020 at 20:58:49 UTC, Marcel wrote: Hello! I have two questions: 1- How can I concatenate two type sequences? alias Concatenated = AliasSeq!(TList1, TList2); or maybe alias Concatenated = AliasSeq!(TList1[0..$], TList2[0..$]); since I don't remember if they nest

Re: CTFE and assoc array

2020-01-19 Thread user1234 via Digitalmars-d-learn
On Sunday, 19 January 2020 at 13:02:18 UTC, Andrey wrote: On Saturday, 18 January 2020 at 21:44:35 UTC, Boris Carvajal wrote: I read that thread. But: Deprecation: initialization of immutable variable from static this is deprecated. Use shared static this instead. And we get? No CTFE with

Re: Type Inference and Try Blocks

2020-01-20 Thread user1234 via Digitalmars-d-learn
On Monday, 20 January 2020 at 23:16:07 UTC, Henry Claesson wrote: This isn't a D-specific "problem", but there may be D-specific solutions. I have a function `doSomething()` that returns a Voldemort type, and this same function also throws. So, there's this: try { auto foo =

Re: Practical parallelization of D compilation

2020-01-08 Thread user1234 via Digitalmars-d-learn
On Wednesday, 8 January 2020 at 04:40:02 UTC, Guillaume Lathoud wrote: Hello, One of my D applications grew from a simple main and a few source files to more than 200 files. Although I minimized usage of templating and CTFE, the compiling time is now about a minute. I did not find any

Re: @disable("reason")

2020-01-08 Thread user1234 via Digitalmars-d-learn
On Wednesday, 8 January 2020 at 00:23:48 UTC, Marcel wrote: Hello! I'm writing a library where under certain conditions i need all the default constructors to be disabled. I would like to tell the user why they can't instantiate the struct. Is there a way to do that? class Example {

Re: Working with cmd

2020-04-18 Thread user1234 via Digitalmars-d-learn
On Friday, 17 April 2020 at 21:38:23 UTC, Quantium wrote: Are there any libs which can be used to access cmd commands? You can pipe cmd.exe: --- import std.process : pipeProcess, ProcessPipes; ProcessPipes pp = pipeProcess(["cmd.exe"]); pp.stdin.writeln("echo foobar"); pp.stdin.close;

Re: [dmd] Types and ScopeDsymbol

2020-04-02 Thread user1234 via Digitalmars-d-learn
On Wednesday, 1 April 2020 at 18:47:38 UTC, drug wrote: Is it true that user defined types are resolved to ScopeDsymbol and basic types aren't? a basic type does not need to introduce a scope since it has no members. All operators on them are supported natively and are no modifiable, so yes

Re: Can’t use UFCS to create InputRange?

2020-04-29 Thread user1234 via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 08:34:53 UTC, Ogi wrote: struct R {} int front(R r) { return 42; } void popFront(R r) {} bool empty(R r) { return false; } void main() { import std.range.primitives : isInputRange; static assert(isInputRange!R); } Error: static assert:

Re: final struct ?

2020-05-19 Thread user1234 via Digitalmars-d-learn
On Tuesday, 19 May 2020 at 10:01:34 UTC, wjoe wrote: As I was reading a few source files of a library I found dozens of final struct declarations like this: final struct Foo { const pure final nothrow bar() { ... } } What's this supposed to express ? A final class is a class that can't

Re: Tuple poilerplate code

2020-08-31 Thread user1234 via Digitalmars-d-learn
On Tuesday, 1 September 2020 at 02:08:54 UTC, JG wrote: Is there anyway to remove the boilerplate code of dealing with tuples: I find myself having to write things like this fairly often auto someRandomName = f(...); //where f returns a tuple with two parts auto firstPart =

Re: Unable to open filename passed as command line argument

2020-09-03 Thread user1234 via Digitalmars-d-learn
On Thursday, 3 September 2020 at 10:47:04 UTC, Curious wrote: Given the following: =a== void main(string[] args) { FILE* fp = fopen(args[1].ptr, "r"); if (!fp) throw new Exception("fopen"); } =b== void main(string[] args) { FILE* fp = fopen(args[1].dup.ptr, "r");

Re: Renaming Flag!"" in API

2020-10-12 Thread user1234 via Digitalmars-d-learn
On Monday, 12 October 2020 at 10:24:44 UTC, FreeSlave wrote: Let's say I use Flag type named 'myflagname' in API like this: import std.typecons; void func(Flag!"myflagname" flag) { //... } void main() { func(Yes.myflagname); } Later I realize that 'myflagname' is a bad name and I want to

Re: Since DMD 2.089.0 and later, compiled .exe showing SFX zip and opening with winRar when use resource.

2020-08-18 Thread user1234 via Digitalmars-d-learn
On Tuesday, 18 August 2020 at 19:01:17 UTC, Marcone wrote: When I compile the source .d code to .exe adding an icon using resource .res file in dmd 2.089.0 and later, the .exe file show SFX zip in it is properties and open with winRar. This ir normal or is a Bug? See images below. Se image

Re: Trying to create a trivial 64 bit D Lang DLL on a Windows 10 machine and cant get past linking.

2020-10-01 Thread user1234 via Digitalmars-d-learn
On Wednesday, 30 September 2020 at 11:45:53 UTC, Ferhat Kurtulmuş wrote: On Tuesday, 29 September 2020 at 21:22:21 UTC, WhatMeWorry wrote: module user; export { int myAddSeven(int a, int b); } [...] it is better to use this template https://github.com/dlang/dmd/tree/master/samples/mydll

Re: final struct ?

2020-05-19 Thread user1234 via Digitalmars-d-learn
On Tuesday, 19 May 2020 at 10:29:51 UTC, wjoe wrote: On Tuesday, 19 May 2020 at 10:08:37 UTC, user1234 wrote: On Tuesday, 19 May 2020 at 10:01:34 UTC, wjoe wrote: [...] It has no purpose. In D many attributes are allowed even if they have no meaning. D-Scanner checks this kind of stuff, to

Re: Alias function declaration.

2020-05-19 Thread user1234 via Digitalmars-d-learn
On Tuesday, 19 May 2020 at 22:04:49 UTC, MaoKo wrote: Hello. I just want to find what is exactly the difference between: alias _ = void function(int); alias void _(int); Because it's seem that the latter can't be used in the declaration of an array (eg: _[] ...). I think the first is a pointer

Re: Question about: ("1.1").to!int;

2020-10-23 Thread user1234 via Digitalmars-d-learn
On Friday, 23 October 2020 at 13:57:41 UTC, Joseph Rushton Wakeling wrote: On Wednesday, 21 October 2020 at 22:50:27 UTC, matheus wrote: Since (1.1).to!int = 1, shouldn't the string value ("1.1").to!int at least try to convert to float/double and then to int? The thing is, that's a great way

Re: Picking function templates with __traits(getOverloads, ..., true)

2020-07-29 Thread user1234 via Digitalmars-d-learn
On Wednesday, 29 July 2020 at 23:57:21 UTC, Jean-Louis Leroy wrote: This works: [...] I may be missing the obvious...or it's a compiler bug??? Yes and it's just been fixed, see https://github.com/dlang/dmd/pull/11431. So uncommenting the second times works on ~master.

Re: __vector(ubyte[32]) misalignment

2020-08-08 Thread user1234 via Digitalmars-d-learn
On Sunday, 9 August 2020 at 01:56:54 UTC, Bruce Carneal wrote: On Sunday, 9 August 2020 at 01:03:51 UTC, Bruce Carneal wrote: The .alignof attribute of __vector(ubyte[32]) is 32 but initializing an array of such vectors via an assignment to .length has given me 16 byte alignment (and

Re: Construct an used-defined hash table container type from an AA-literal expression

2020-07-05 Thread user1234 via Digitalmars-d-learn
On Sunday, 5 July 2020 at 21:06:32 UTC, Per Nordlöw wrote: Is there a way to construct a custom written hash-table container (struct) from an AA-literal expression? How about iterating the literal, e.g --- foreach (k,v; ["one":1, "two":2]) { myCustomAA[k] = v; } ---

Re: Construct an used-defined hash table container type from an AA-literal expression

2020-07-05 Thread user1234 via Digitalmars-d-learn
On Sunday, 5 July 2020 at 21:38:12 UTC, Per Nordlöw wrote: On Sunday, 5 July 2020 at 21:22:13 UTC, ikod wrote: struct AA(K,V) { void opAssign(V[K] aa) { } } void main() { AA!(string, int) custom_aa; custom_aa = ["one":1, "two":2]; } Forget to mention that I want the

Re: Uploading coverage to Codecov doesn't work

2020-07-08 Thread user1234 via Digitalmars-d-learn
On Wednesday, 8 July 2020 at 15:55:58 UTC, Mitacha wrote: Hello there, I've been trying to setup bitbucket pipelines to submit coverage to codecov, but with no luck. I use `dub run -b unittest-cov` and it generates .lst files correctly, then `bash <(curl -s https://codecov.io/bash) -t

Re: dmd release schedule?

2020-07-04 Thread user1234 via Digitalmars-d-learn
On Saturday, 4 July 2020 at 20:48:02 UTC, drathier wrote: On Sunday, 28 June 2020 at 10:44:26 UTC, drathier wrote: Is there a release schedule anywhere for DMD? Any list of tasks to be the next release? I'm only finding 5+ year old things when searching. Yes:

Re: Rules for Symbol Name Lookup seem contradictory

2020-06-21 Thread user1234 via Digitalmars-d-learn
On Monday, 22 June 2020 at 01:38:41 UTC, Manfred Nowak wrote: https://dlang.org/spec/module.html#name_lookup contains under 4.3.4 only two sentences. While the first sentence explains, that the search ends "as soon as a matching symbol is found", the second sentence implies that the search

Re: Passing a variable number of slices into a function

2020-06-21 Thread user1234 via Digitalmars-d-learn
On Monday, 22 June 2020 at 01:47:49 UTC, repr-man wrote: Is there any way to pass an unknown number of slices into a function? I'm trying to do something along the lines of: void func(T)(T[] args...) { //... } That wasn't working, [...] Thanks for the help! Can you provide more

Re: Should a parser type be a struct or class?

2020-06-17 Thread user1234 via Digitalmars-d-learn
On Wednesday, 17 June 2020 at 11:50:27 UTC, Per Nordlöw wrote: Should a range-compliant aggregate type realizing a parser be encoded as a struct or class? In dmd `Lexer` and `Parser` are both classes. In general how should I reason about whether an aggregate type should be encoded as a

Re: Request assistance initializing struct instance at global scope

2020-12-06 Thread user1234 via Digitalmars-d-learn
On Monday, 7 December 2020 at 05:28:41 UTC, user1234 wrote: On Monday, 7 December 2020 at 04:13:16 UTC, Andrew Edwards wrote: Given: === extern(C): char*[] hldr; enum I = (1<<0); struct S { char* ft; char** fm; int f; } void main(){} === How do I initialize an

Re: Request assistance initializing struct instance at global scope

2020-12-06 Thread user1234 via Digitalmars-d-learn
On Monday, 7 December 2020 at 04:13:16 UTC, Andrew Edwards wrote: Given: === extern(C): char*[] hldr; enum I = (1<<0); struct S { char* ft; char** fm; int f; } void main(){} === How do I initialize an instance of S at global scope? You cant. At the global scope the

Re: ParameterIdentifierTuple returns empty strings

2020-12-02 Thread user1234 via Digitalmars-d-learn
On Wednesday, 2 December 2020 at 11:46:26 UTC, Andre Pany wrote: Hi, I need to retrieve the parameter identifier but only empty strings are returned: tuple("", "") ``` d alias fpt = extern(C) nothrow void function(int a, int b); void main() { import std.traits :

Re: New vs length on dymamic array

2020-11-09 Thread user1234 via Digitalmars-d-learn
On Monday, 9 November 2020 at 08:06:54 UTC, Andrey wrote: Hello, Are here any differences in creation of dynamic array with known size? auto array = new wchar[](111); and wchar[] array; array.length = 111; It's the same. If the two are valid then you are in a function. So it's an

Re: How to debug D on Linux

2021-01-13 Thread user1234 via Digitalmars-d-learn
On Wednesday, 13 January 2021 at 13:47:55 UTC, Roguish wrote: On Wednesday, 13 January 2021 at 13:30:48 UTC, Roguish wrote: Anything else I need to know when debugging on Linux, without an IDE? One specific question I have is: what's the difference between -g and -debug and -d-debug? Also,

Re: How to select the regex that matches the first token of a string?

2021-07-03 Thread user1234 via Digitalmars-d-learn
On Saturday, 3 July 2021 at 09:05:28 UTC, vnr wrote: Hello, I am trying to make a small generic lexer that bases its token analysis on regular expressions. The principle I have in mind is to define a token type table with its corresponding regular expression, here is the code I currently

Re: Since dmd 2.096.0: import `x.t` is used as a type

2021-04-30 Thread user1234 via Digitalmars-d-learn
On Friday, 30 April 2021 at 17:58:43 UTC, kdevel wrote: dmd since 2.096.0 with ``t.d`` ```t.d module t; class t { } ``` and ``x.d`` ```x.d module x; import t; void main () { t x = new t; } ``` reports $ dmd -i x.d x.d(6): Error: import `x.t` is used as a type x.d(6): Error:

Re: Deriving a D-class from a CPP-class

2021-04-29 Thread user1234 via Digitalmars-d-learn
On Thursday, 29 April 2021 at 06:38:53 UTC, evilrat wrote: On Wednesday, 28 April 2021 at 19:46:00 UTC, Alain De Vos wrote: It is rather clear what I want to achieve but virtual functions give me headache because dlang does not now the word virtual. It's virtual by default. The opposite is

Re: dlang vs crystal-language

2021-05-03 Thread user1234 via Digitalmars-d-learn
On Saturday, 1 May 2021 at 13:04:15 UTC, sighoya wrote: On Wednesday, 28 April 2021 at 22:41:03 UTC, Alain De Vos wrote: What are the strengths and weaknesses comparing the two languages ? I can name a strength of dlang is the working binding to tk and gtk. Just to say, Crystal is a neat

Re: Static array initialisation

2021-04-01 Thread user1234 via Digitalmars-d-learn
On Thursday, 1 April 2021 at 09:30:28 UTC, DLearner wrote: On Wednesday, 31 March 2021 at 23:21:59 UTC, russhy wrote: On Wednesday, 31 March 2021 at 17:54:38 UTC, DLearner wrote: [...] Can you show the print function? Maybe the problem lies there? Using rdmd, I believe the code below

Re: rdmd and D equivalent for PYTHONPATH?

2021-03-17 Thread user1234 via Digitalmars-d-learn
On Wednesday, 17 March 2021 at 04:34:07 UTC, Chris Piker wrote: On Wednesday, 17 March 2021 at 03:43:22 UTC, Chris Piker wrote: Note: I'm aware of dub. This isn't a question about dub. I'm making scripts for local use, not redistributable binaries, so I would like to "install" mir-algorithm

  1   2   3   >