Re: Is it possible to use DMD as a library to compile strings at runtime?

2020-01-31 Thread Basile B. via Digitalmars-d-learn
On Friday, 31 January 2020 at 11:19:37 UTC, Saurabh Das wrote: I see that DUB has DMD as a library package, but I was not able to understand how to use it. Is it possible to use DMD as a library within a D program to compile a string to machine code and run the compiled code at runtime?

Re: list of all defined items in a D file

2020-01-25 Thread Basile B. via Digitalmars-d-learn
On Friday, 24 January 2020 at 14:28:03 UTC, berni44 wrote: On Friday, 24 January 2020 at 12:22:49 UTC, Dennis wrote: You can pass the -X flag to dmd, which makes it generate a .json file describing the compiled file. Great, that's what I was looking for - although it's also good to know the

Re: compiler error when trying to get random key from AA

2020-01-25 Thread Basile B. via Digitalmars-d-learn
On Saturday, 25 January 2020 at 09:18:01 UTC, Basile B. wrote: On Saturday, 25 January 2020 at 08:35:18 UTC, mark wrote: I have this code: import std.random; import std.stdio; void main() { auto aa = ["one": 1, "two": 2, "three": 3]; writeln(aa); auto rnd = rndGen; auto word =

Re: compiler error when trying to get random key from AA

2020-01-25 Thread Basile B. via Digitalmars-d-learn
On Saturday, 25 January 2020 at 08:35:18 UTC, mark wrote: I have this code: import std.random; import std.stdio; void main() { auto aa = ["one": 1, "two": 2, "three": 3]; writeln(aa); auto rnd = rndGen; auto word = aa.byKey.choice(rnd); writeln(word); } And in the D

Re: compiler error when trying to get random key from AA

2020-01-25 Thread Basile B. via Digitalmars-d-learn
On Saturday, 25 January 2020 at 08:35:18 UTC, mark wrote: I have this code: import std.random; import std.stdio; void main() { auto aa = ["one": 1, "two": 2, "three": 3]; writeln(aa); auto rnd = rndGen; auto word = aa.byKey.choice(rnd); writeln(word); } And in the D

Re: compiler error when trying to get random key from AA

2020-01-25 Thread Basile B. via Digitalmars-d-learn
On Saturday, 25 January 2020 at 09:06:53 UTC, mark wrote: On Saturday, 25 January 2020 at 08:59:23 UTC, Basile B. wrote: On Saturday, 25 January 2020 at 08:35:18 UTC, mark wrote: [...] [snip] [...] rndGen is a range. Use `auto word = aa.byKey.choice(rnd.front())` as index instead. Then

Re: compiler error when trying to get random key from AA

2020-01-25 Thread Basile B. via Digitalmars-d-learn
On Saturday, 25 January 2020 at 08:59:23 UTC, Basile B. wrote: On Saturday, 25 January 2020 at 08:35:18 UTC, mark wrote: [...] rndGen is a range. Use `auto word = aa.byKey.choice(rnd.front())` as index instead. Then `rndGen.popFront()` to advance. no sorry, I didn't read and thought you

Re: compiler error when trying to get random key from AA

2020-01-25 Thread Basile B. via Digitalmars-d-learn
On Saturday, 25 January 2020 at 08:35:18 UTC, mark wrote: I have this code: import std.random; import std.stdio; void main() { auto aa = ["one": 1, "two": 2, "three": 3]; writeln(aa); auto rnd = rndGen; auto word = aa.byKey.choice(rnd); writeln(word); } And in the D

Re: needing to change the order of things at module level = compiler bug, right?

2019-12-11 Thread Basile B. via Digitalmars-d-learn
On Sunday, 8 December 2019 at 18:13:59 UTC, DanielG wrote: On Sunday, 8 December 2019 at 18:01:03 UTC, Steven Schveighoffer wrote: Yes, if it can compile when you move things around, and the result is *correct* (very important characteristic) Indeed, everything's working as intended when

Re: Unexpectedly nice case of auto return type

2019-12-06 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 4 December 2019 at 12:54:34 UTC, Basile B. wrote: On Wednesday, 4 December 2019 at 03:17:27 UTC, Adam D. Ruppe wrote: On Wednesday, 4 December 2019 at 01:28:00 UTC, H. S. Teoh wrote: typeof(return) is one of the lesser known cool things about D that make it so cool. Somebody

Re: opCmp with and without const

2019-12-06 Thread Basile B. via Digitalmars-d-learn
On Friday, 6 December 2019 at 07:03:45 UTC, berni44 wrote: In std.typecons, in Tuple there are two opCmp functions, that are almost identical; they only differ by one being const and the other not: int opCmp(R)(R rhs) if (areCompatibleTuples!(typeof(this), R, "<")) {

Re: confused about template constructors and implicit type conversions

2019-12-04 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 4 December 2019 at 23:53:53 UTC, NeeO wrote: Would someone be able to explain this ? I can only seem to call a template constructor in one way, but I can't seem to pass what looks like an accepted type to the template constructor via a function call. /+ main.d +/ import

Re: Unexpectedly nice case of auto return type

2019-12-04 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 4 December 2019 at 03:17:27 UTC, Adam D. Ruppe wrote: On Wednesday, 4 December 2019 at 01:28:00 UTC, H. S. Teoh wrote: typeof(return) is one of the lesser known cool things about D that make it so cool. Somebody should write an article about it to raise awareness of it. :-D

Re: Unexpectedly nice case of auto return type

2019-12-04 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 10:19:02 UTC, Jonathan M Davis wrote: On Tuesday, December 3, 2019 3:03:22 AM MST Basile B. via Digitalmars-d- learn wrote: On Tuesday, 3 December 2019 at 09:58:36 UTC, Jonathan M Davis wrote: > On Tuesday, December 3, 2019 12:12:18 AM MST Basile B.

Re: Unexpectedly nice case of auto return type

2019-12-04 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 23:44:59 UTC, mipri wrote: On Tuesday, 3 December 2019 at 10:13:30 UTC, mipri wrote: Speaking of nice stuff and aliases, suppose you want to return a nice tuple with named elements? Option 1: auto auto option1() { return tuple!(int, "apples", int,

Re: Floating-Point arithmetic in dlang - Difference to other languages

2019-12-03 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 09:22:49 UTC, Jan Hönig wrote: Today i have stumbled on Hacker News into: https://0.30004.com/ I am learning D, that's why i have to ask. Why does writefln("%.17f", .1+.2); not evaluate into: 0.30004, like C++ but rather to:

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 10:19:02 UTC, Jonathan M Davis wrote: On Tuesday, December 3, 2019 3:03:22 AM MST Basile B. via Digitalmars-d- learn wrote: [...] There isn't much point in giving the type of null an explicit name given that it doesn't come up very often, and typeof(null

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 09:58:36 UTC, Jonathan M Davis wrote: On Tuesday, December 3, 2019 12:12:18 AM MST Basile B. via Digitalmars-d- learn wrote: I wish something like this was possible, until I change the return type of `alwaysReturnNull` from `void*` to `auto`. --- class

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 09:44:20 UTC, Basile B. wrote: On Tuesday, 3 December 2019 at 08:47:45 UTC, Andrea Fontana wrote: On Tuesday, 3 December 2019 at 07:24:31 UTC, Basile B. wrote: A testA() { return alwaysReturnNull(); // Tnull can be implictly converted to A

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 08:47:45 UTC, Andrea Fontana wrote: On Tuesday, 3 December 2019 at 07:24:31 UTC, Basile B. wrote: A testA() { return alwaysReturnNull(); // Tnull can be implictly converted to A } still nice tho. Why not [1]? [1] typeof(null)

Re: Unexpectedly nice case of auto return type

2019-12-02 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 07:12:18 UTC, Basile B. wrote: I wish something like this was possible, until I change the return type of `alwaysReturnNull` from `void*` to `auto`. --- class A {} class B {} auto alwaysReturnNull() // void*, don't compile { writeln(); return null; } A

Unexpectedly nice case of auto return type

2019-12-02 Thread Basile B. via Digitalmars-d-learn
I wish something like this was possible, until I change the return type of `alwaysReturnNull` from `void*` to `auto`. --- class A {} class B {} auto alwaysReturnNull() // void*, don't compile { writeln(); return null; } A testA() { return alwaysReturnNull(); } B testB() {

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

2019-11-15 Thread Basile B. via Digitalmars-d-learn
On Friday, 15 November 2019 at 10:55:55 UTC, IGotD- wrote: On Friday, 15 November 2019 at 08:58:43 UTC, user1234 wrote: 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

Re: Unexpected aliasing

2019-11-12 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 12 November 2019 at 07:59:39 UTC, Bastiaan Veelo wrote: On Monday, 11 November 2019 at 20:05:11 UTC, Antonio Corbi wrote: [...] Thanks, Antonio. My problem is that the length of the array should be a built-in property of WrapIntegerArray (immutable in this case); what I'd

Re: How would I write a travis-ci file for a Meson Dlang project?

2019-07-16 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 16 July 2019 at 15:07:11 UTC, Mike Brockus wrote: If you never seen Meson before then pick up a camera and take a picture: 樂  https://mesonbuild.com/ Hello, everyone. I started adding continues integration as part of my development cycle and I was wondering how would I write a

Re: Is there any way to define an interface that can implicitly convert to Object?

2019-07-10 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 10 July 2019 at 08:03:30 UTC, Nathan S. wrote: I want to be able to do things like: --- bool isSame(Object a, Object b) { return a is b; } interface SomeInterface { int whatever(); } bool failsToCompile(SomeInterface a, SomeInterface b) { return isSame(a, b); } --- Error:

Re: Mixin mangled name

2019-07-03 Thread Basile B. via Digitalmars-d-learn
On Monday, 1 July 2019 at 23:52:49 UTC, Andrey wrote: Hello, Is it possible to mixin in code a mangled name of some entity so that compiler didn't emit undefined symbol error? For example mangled function name or template parameter? Yes. An example from the DMD test suite itself :

Re: Is it possible to escape a reserved keyword in Import/module?

2019-06-19 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 19 June 2019 at 21:21:53 UTC, XavierAP wrote: On Wednesday, 19 June 2019 at 18:56:57 UTC, BoQsc wrote: I would like to make sure that my modules do not interfere with d lang. Is there any way to escape reserved words? The only reason C# allows this is for interop or code

Re: Is it possible to escape a reserved keyword in Import/module?

2019-06-19 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 19 June 2019 at 19:07:30 UTC, Jonathan M Davis wrote: On Wednesday, June 19, 2019 12:56:57 PM MDT BoQsc via Digitalmars-d-learn wrote: I would like to make sure that my modules do not interfere with d lang. Is there any way to escape reserved words?

Re: D compiler need -nogc witch and document of library also need nogc button

2019-06-11 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 11 June 2019 at 08:08:14 UTC, Basile B. wrote: On Tuesday, 11 June 2019 at 08:05:31 UTC, dangbinghoo wrote: hi there, I think that D compiler needs -nogc switch to fully disable gc for a project, and document of phobos also needs a friendly way to list-out all @nogc API. we

Re: D compiler need -nogc witch and document of library also need nogc button

2019-06-11 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 11 June 2019 at 08:05:31 UTC, dangbinghoo wrote: hi there, I think that D compiler needs -nogc switch to fully disable gc for a project, and document of phobos also needs a friendly way to list-out all @nogc API. we already have -betterC, and betterC disabled GC, why we could

Re: Very simple null reference escape

2019-06-02 Thread Basile B. via Digitalmars-d-learn
On Sunday, 2 June 2019 at 07:55:27 UTC, Amex wrote: A.B If A is null, crash. A?.B : writeln("HAHA"); No crash, ignored, equivalent to if (A is null) writeln("HAHA"); else A.B; safeAccess from iz does this : https://github.com/Basile-z/iz/blob/master/import/iz/sugar.d#L1666

Re: import and call

2019-06-02 Thread Basile B. via Digitalmars-d-learn
On Sunday, 2 June 2019 at 19:38:11 UTC, Amex wrote: Tired of having to import a single function to call it. Since mod.foo(x); doesn't work since mod is not defined. we have to do import mod : foo; foo(x); Why not mod:foo(x)? or mod#foo(x) or mod@foo(x) or whatever Reduces 50% of

Re: Bitfields

2019-05-22 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 22 May 2019 at 08:54:45 UTC, Russel Winder wrote: On Tue, 2019-05-21 at 19:14 +, Era Scarecrow via Digitalmars-d-learn wrote: […] I worked on/with bitfields in the past, the limit sizes is more or less for natural int types that D supports. Rust bitfield crate and it's

Re: Performance of tables slower than built in?

2019-05-22 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 22 May 2019 at 08:25:58 UTC, Basile B. wrote: On Wednesday, 22 May 2019 at 00:22:09 UTC, JS wrote: I am trying to create some fast sin, sinc, and exponential routines to speed up some code by using tables... but it seems it's slower than the function itself?!? [...] Hi,

Re: Performance of tables slower than built in?

2019-05-22 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 22 May 2019 at 00:22:09 UTC, JS wrote: I am trying to create some fast sin, sinc, and exponential routines to speed up some code by using tables... but it seems it's slower than the function itself?!? [...] Hi, lookup tables ARE faster but the problem you have here, and I'm

Re: Efficient enum array keys?

2019-04-11 Thread Basile B. via Digitalmars-d-learn
On Thursday, 11 April 2019 at 07:56:42 UTC, Julian wrote: On Thursday, 11 April 2019 at 06:45:23 UTC, Basile B. wrote: On Thursday, 11 April 2019 at 06:20:05 UTC, Julian wrote: I don't see a difference in micro-benchmarks. *shrug* Your enum is int so in machine code it's exactly like

Re: Efficient enum array keys?

2019-04-11 Thread Basile B. via Digitalmars-d-learn
On Thursday, 11 April 2019 at 06:20:05 UTC, Julian wrote: Hello, When reading through the following D blog post, I noticed in the feature chart that D had "Arrays beginning at arbitrary indices" as a +1 feature, the same as in Ada.

Re: Setting the GtkD Include Path in dexed?

2019-03-14 Thread Basile B. via Digitalmars-d-learn
On Thursday, 14 March 2019 at 20:06:08 UTC, Ron Tarrant wrote: On Thursday, 14 March 2019 at 16:02:01 UTC, Basile B. wrote: You must register put the static library file, not the object I thing, anyway, i just made you a video showing exactly what to do since finally the linker error is gone

Re: Setting the GtkD Include Path in dexed?

2019-03-14 Thread Basile B. via Digitalmars-d-learn
On Thursday, 14 March 2019 at 15:50:55 UTC, Ron Tarrant wrote: Thanks for replying, Basile. It's always nice to get info straight from the original code author. :) On Wednesday, 13 March 2019 at 11:59:11 UTC, Basile B. wrote: 1. "Compile File and Run" It's for the scripts-like program, i.e

Re: Setting the GtkD Include Path in dexed?

2019-03-14 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 12 March 2019 at 15:48:14 UTC, Ron Tarrant wrote: I managed to get dexed to compile a single-file dub project, but for completeness sake, I'm also trying to configure it to use dmd (non-dub) to compile GtkD projects using Compilation (menu) > Compile File and Run. To that end, I

Re: Setting the GtkD Include Path in dexed?

2019-03-13 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 12 March 2019 at 15:48:14 UTC, Ron Tarrant wrote: I managed to get dexed to compile a single-file dub project, but for completeness sake, I'm also trying to configure it to use dmd (non-dub) to compile GtkD projects using Compilation (menu) > Compile File and Run. To that end, I

Re: AliasSeq in UDA

2019-03-10 Thread Basile B. via Digitalmars-d-learn
On Sunday, 10 March 2019 at 17:04:20 UTC, Sebastiaan Koppe wrote: On Sunday, 10 March 2019 at 16:46:43 UTC, Basile B. wrote: Yes I see. I've refined a bit the test case and maybe I'll took a look this week. Cool. Is it normal to create a testcase that doesn't depend on phobos? I suppose it

Re: AliasSeq in UDA

2019-03-10 Thread Basile B. via Digitalmars-d-learn
On Sunday, 10 March 2019 at 16:05:19 UTC, Sebastiaan Koppe wrote: On Sunday, 10 March 2019 at 13:41:32 UTC, Basile B. wrote: It looks like a bug, a "reject-valid" one. Try the same code with enum A = 0; and it work, despite of B being still opaque. The problem may be related to the fact

Re: AliasSeq in UDA

2019-03-10 Thread Basile B. via Digitalmars-d-learn
On Sunday, 10 March 2019 at 13:20:12 UTC, Sebastiaan Koppe wrote: The compiler complains about `cannot form tuple of tuples` whenever I try to put an AliasSeq in a UDA and try to use it. You would expect the compiler to expand it. Is this a bug? --- import std.meta; enum A; enum B;

Re: AliasSeq in UDA

2019-03-10 Thread Basile B. via Digitalmars-d-learn
On Sunday, 10 March 2019 at 13:41:32 UTC, Basile B. wrote: On Sunday, 10 March 2019 at 13:20:12 UTC, Sebastiaan Koppe wrote: The compiler complains about `cannot form tuple of tuples` whenever I try to put an AliasSeq in a UDA and try to use it. You would expect the compiler to expand it. Is

Re: Handling signals in D

2018-12-26 Thread Basile B via Digitalmars-d-learn
On Wednesday, 26 December 2018 at 03:19:45 UTC, Norbert Preining wrote: Hello everyone, we are writing a program that synchronizes the OneDrive cloud service with the local computer, and run it as daemon in the background. To ensure proper database shutdown on exit, we need to install signal

Re: class template conflict

2018-12-23 Thread Basile B. via Digitalmars-d-learn
On Sunday, 23 December 2018 at 12:09:31 UTC, Michelle Long wrote: class X { } class X(int N) : X { } Is there any real reason we can't do this? It is very nice to be able to treat X like the base and X!n as a derived class. Sure we can do class X(int N) : X!0 { static if(N == 0) {

Re: Mixin operator 'if' directly

2018-12-22 Thread Basile B. via Digitalmars-d-learn
On Saturday, 22 December 2018 at 10:11:23 UTC, bauss wrote: On Saturday, 22 December 2018 at 03:44:09 UTC, Timoses wrote: Awesome hack! Being a hack, it would be even nicer if it worked ouf of the box: mixin template foo(bool b) { int _impl() { writeln(b); return int.init; }

Re: Compiling a template

2018-12-06 Thread Basile B. via Digitalmars-d-learn
On Thursday, 6 December 2018 at 22:50:49 UTC, albertas-jn wrote: If templates are a compile-time feature and instances of templates are generated by compiler at compile time, why is it possible to compile a template definition with dmd -lib or -c? Because to instantiate the source code is

Re: struct sta­tic ini­tial­izer method apply to UDA

2018-12-06 Thread Basile B. via Digitalmars-d-learn
On Thursday, 6 December 2018 at 11:04:23 UTC, learnfirst1 wrote: my question is how to easy use struct sta­tic ini­tial­izer method with UDA. Fake code: struct DbColumn { string name; boolunique ; boolsigned ; boolnullable ; } struct Order {

Re: Non-blocking reads of a fifo (named pipe)?

2018-12-03 Thread Basile B. via Digitalmars-d-learn
On Monday, 3 December 2018 at 23:32:10 UTC, Anonymouse wrote: I have a fifo that I want to read lines from, but everything is blocking. [...] How can I go about doing this to get non-blocking reads? Or perhaps a way to test whether there is text waiting in the fifo? File.eof is not it. [...]

Re: __traits for checking if a type is dynamic array (slice)

2018-11-26 Thread Basile B. via Digitalmars-d-learn
On Monday, 26 November 2018 at 09:04:25 UTC, Per Nordlöw wrote: Why is there no - __traits(isArray, T) alongside - __traits(isStaticArray, T) and - __traits(isAssociativeArray, T) when dmd already has `ENUMTY.Tarray` alongside - ENUMTY.Tsarray and - ENUMTY.Taarray and std.traits already

Re: Fields with the same name not causing a warning?

2018-11-16 Thread Basile B. via Digitalmars-d-learn
On Friday, 16 November 2018 at 17:28:15 UTC, Vinay Sajip wrote: On Friday, 16 November 2018 at 17:08:00 UTC, Basile B. wrote: I agree that this is almost a case of shadowing but i don't know the exact rationale for allowing this. I'm not saying it shouldn't be allowed - just that the

Re: Fields with the same name not causing a warning?

2018-11-16 Thread Basile B. via Digitalmars-d-learn
On Friday, 16 November 2018 at 15:59:14 UTC, Vinay Sajip wrote: This code should IMO give at least a warning, but it doesn't: abstract class A { int kind; } class B : A { int kind; this(int k) { kind = k; } } In my actual code, the declaration of field "kind" in B was

Re: Not able to load classes defined in archive file in Mac OSX using Object.factory

2018-11-16 Thread Basile B. via Digitalmars-d-learn
On Friday, 16 November 2018 at 14:55:52 UTC, Aditya wrote: On Friday, 16 November 2018 at 14:30:02 UTC, Adam D. Ruppe wrote: PS object.factory sucks and I hope it is removed some day. There's no plan to do so, but I still wouldn't actually rely on it... instead, I'd write your own factory

Re: Inherit from class based on bool value

2018-11-13 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 13 November 2018 at 07:10:26 UTC, Jamie wrote: I would like my class to inherit from one of two classes based on a boolean value known at compile time. Something like this: void main() { Top!(OPTION.FALSE) top = new Top!(OPTION.FALSE); } enum OPTION { FALSE = 0., TRUE

Re: Noob question about structs allocation

2018-10-14 Thread Basile B. via Digitalmars-d-learn
On Monday, 15 October 2018 at 03:19:07 UTC, IM wrote: I probably used to know the answer to this question, but it's been a long time since I last used D, and I don't remember. Suppose we have: struct S { int num; } Would allocating an instance on the heap using: S* s = new S; use the GC,

Re: Help about Template and class inheritance

2018-10-14 Thread Basile B. via Digitalmars-d-learn
On Sunday, 14 October 2018 at 13:21:00 UTC, Heromyth wrote: Here is a sample code ```d import std.stdio; class Future(T) { T result; this(T r) { this.result = r; } } interface IExecutorService { // Future!(T) submit(T)(T result); // can't be

Re: Has Anyone has this same Issue Please?

2018-10-12 Thread Basile B. via Digitalmars-d-learn
On Thursday, 11 October 2018 at 18:20:56 UTC, Ephrahim wrote: Using this dub.json configuration 0.8.36\eventcore\source\eventcore\drivers\posix\driver.d(145,14): Error: safe function 'eventcore.drivers.posix.driver.PosixEventDriverCore!(SelectEventLoop, LoopTimeoutTimerDriver,

Re: Is there a function for this?

2018-10-06 Thread Basile B via Digitalmars-d-learn
On Saturday, 6 October 2018 at 13:56:32 UTC, bauss wrote: On Saturday, 6 October 2018 at 13:35:38 UTC, Basile B wrote: On Saturday, 6 October 2018 at 13:17:22 UTC, bauss wrote: Let's say you have a range with struct, but some of the struct are duplicates of each other. Is there a standard

Re: Is there a function for this?

2018-10-06 Thread Basile B via Digitalmars-d-learn
On Saturday, 6 October 2018 at 13:17:22 UTC, bauss wrote: Let's say you have a range with struct, but some of the struct are duplicates of each other. Is there a standard function in Phobos to remove duplicates? My first thought was "uniq", but it can't really do it like that, but it doesn't

Re: Linking with a non-default druntime

2018-10-02 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 2 October 2018 at 13:07:04 UTC, Basile B. wrote: On Monday, 1 October 2018 at 11:10:07 UTC, Per Nordlöw wrote: On Monday, 1 October 2018 at 08:27:54 UTC, Basile B. wrote: I think so. Apparently it's registered with a string, e.g "manual" and you pass a special druntime option with

Re: Dlang tour - Unittesting example

2018-10-02 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 2 October 2018 at 12:30:36 UTC, Joe wrote: On Tuesday, 2 October 2018 at 12:25:19 UTC, Joe wrote: On Tuesday, 2 October 2018 at 09:59:28 UTC, bauss wrote: On Tuesday, 2 October 2018 at 04:13:01 UTC, Joe wrote: There appears to be a problem with the example at

Re: Linking with a non-default druntime

2018-10-02 Thread Basile B. via Digitalmars-d-learn
On Monday, 1 October 2018 at 11:10:07 UTC, Per Nordlöw wrote: On Monday, 1 October 2018 at 08:27:54 UTC, Basile B. wrote: I think so. Apparently it's registered with a string, e.g "manual" and you pass a special druntime option with your program to select. Actually i would be interested to

Re: Invalid string literal in ASM

2018-10-01 Thread Basile B. via Digitalmars-d-learn
On Monday, 1 October 2018 at 09:24:47 UTC, Basile B. wrote: On Monday, 1 October 2018 at 08:14:07 UTC, dokutoku wrote: I get a compiler error when I try to put non-ASCII characters in a string literal in the inline assembler. Is this part of the specifications? It's not clear, see

Re: Invalid string literal in ASM

2018-10-01 Thread Basile B. via Digitalmars-d-learn
On Monday, 1 October 2018 at 08:14:07 UTC, dokutoku wrote: I get a compiler error when I try to put non-ASCII characters in a string literal in the inline assembler. Is this part of the specifications? It's not clear, see https://dlang.org/spec/iasm.html#raw_data: "if an operand is a string

Re: Linking with a non-default druntime

2018-10-01 Thread Basile B. via Digitalmars-d-learn
On Monday, 1 October 2018 at 07:17:59 UTC, Per Nordlöw wrote: On Sunday, 30 September 2018 at 19:53:02 UTC, Basile B. wrote: this way you can very easily change-compile-test, without recompiling the whole runtime and phobos each time. Ok, thanks. Is it possible to register an extra GC in a

Re: Linking with a non-default druntime

2018-09-30 Thread Basile B. via Digitalmars-d-learn
On Sunday, 30 September 2018 at 19:03:17 UTC, Per Nordlöw wrote: How can I link my dmd-compiled program with a specific version of the druntime? druntime is within libphobos. So you must change this. I need this when experimenting with a new GC. Did you try what i proposed earlier ? Until

Re: inline ASM function calling conventions.

2018-09-30 Thread Basile B. via Digitalmars-d-learn
On Sunday, 30 September 2018 at 11:53:17 UTC, Basile B. wrote: On Sunday, 30 September 2018 at 10:46:33 UTC, Sjoerd Nijboer wrote: [...] Hello, i think this should be here (https://dlang.org/spec/abi.html) because myself i never remember them correctly without playing a bit with a

Re: inline ASM function calling conventions.

2018-09-30 Thread Basile B. via Digitalmars-d-learn
On Sunday, 30 September 2018 at 10:46:33 UTC, Sjoerd Nijboer wrote: I'm kinda puzzled. I'm having trouble getting started with inline asm in D. Suppowse I have the following: void Foo(MyStrunct* first_arg, MyStrunct* second_arg) { asm { naked; version(X86) {

Re: dealing with very long paths and names

2018-09-14 Thread Basile B. via Digitalmars-d-learn
On Friday, 14 September 2018 at 17:59:38 UTC, Josphe Brigmo wrote: Seems to break dirEntries when trying to deal with long pathnames(> 512) on windows. It's a strange error because it just fails with access denied or missing file. The bug is known, see

Re: traits getOverload of a template method

2018-09-11 Thread Basile B. via Digitalmars-d-learn
On Thursday, 6 February 2014 at 23:06:03 UTC, QAston wrote: How do i get aliases to overloads of a template method like Class A { int a(T)(T tq,T tw); int a(T)(T tq); } __traits(getOverloads, A, "a(int)")doesnt work Support for template in the getOverloads trait has been added

Re: Error: expression `update` of type `void` does not have a boolean value

2018-09-08 Thread Basile B. via Digitalmars-d-learn
On Saturday, 8 September 2018 at 03:12:56 UTC, Josphe Brigmo wrote: auto foo(bool update = false)() { static if(update) { } } and the compiler, after upgrading to 2.082 from 2.080 now says: Error: expression `update` of type `void` does not have a boolean value when update is

Re: std.process: spawnProcess

2018-09-07 Thread Basile B. via Digitalmars-d-learn
On Friday, 7 September 2018 at 14:36:42 UTC, Russel Winder wrote: From what I can see, processes created with std.process: spawnProcess are not terminated when the creating process terminates, i.e. it seems Config.detached is the default for these process. Is there a way of all spawned

Re: Static foreach internal variable

2018-08-30 Thread Basile B. via Digitalmars-d-learn
On Thursday, 30 August 2018 at 08:19:47 UTC, Andrey wrote: Hello, is it possible to declare an internal variable in "static foreach" and on each iteration assign something to it? Example: static foreach(arg; SomeAliasSeq) { internal = arg[0].converted;// a shortcut for expression

Re: Null-Coalescing Operator and Extensions

2018-08-27 Thread Basile B. via Digitalmars-d-learn
On Monday, 27 August 2018 at 14:59:20 UTC, SG wrote: On Monday, 27 August 2018 at 07:59:17 UTC, Simen Kjærås wrote: That's the null propagation operator (?.). What SG asked for is the null-coalescing operator (??). Of course, this can also be implemented in D (albeit with a slight more

Re: Null-Coalescing Operator and Extensions

2018-08-27 Thread Basile B. via Digitalmars-d-learn
On Saturday, 25 August 2018 at 19:16:26 UTC, Jacob Carlborg wrote: On 2018-08-25 15:33, SG wrote: Hi, 1) I program in C# and I'm wondering if there is something like ?? (Null-Coalescing Operator) in D? (I remember some proposals in the past). Not in the language but it can be implemented

Re: Make function alias

2018-08-20 Thread Basile B. via Digitalmars-d-learn
On Monday, 20 August 2018 at 13:14:14 UTC, Andrey wrote: Hello, I want to make an alias to function "std.stdio.writeln" and "std.stdio.write" and use it like: static void log(bool newline = true)(string text) { alias print(T...) = newline ? : _file.print(); text.print(); }

Re: UDA on double nested struct

2018-08-20 Thread Basile B. via Digitalmars-d-learn
On Monday, 20 August 2018 at 16:16:04 UTC, Sebastiaan Koppe wrote: Hey, I am trying to get UDAs from a doubly nested struct, to no avail: code --- import std.traits : hasUDA; enum hover; struct Style { struct Root { auto margin = "10px"; auto backgroundColor = "white"; @hover

Re: How to phrase RIP addressing in assembly under Linux AMD64

2018-08-19 Thread Basile B. via Digitalmars-d-learn
On Sunday, 19 August 2018 at 07:18:20 UTC, Sean O'Connor wrote: How to I phrase RIP addressing in assembly under Linux AMD64 in D. I can't seem to figure it out. Normally I do something like: movq rax,rndphi[rip] Where rndphi is a label pointing to data. I know I have change movq to mov in

Re: getProtection gives different result when member is accessed via getMember

2018-08-06 Thread Basile B. via Digitalmars-d-learn
On Sunday, 5 August 2018 at 01:48:08 UTC, Yuxuan Shui wrote: file1.d: import std.stdio; file2.d: import file1; pragma(msg, __traits(getProtection, __traits(getMember, m1, "std"))); // public pragma(msg, __traits(getProtection, m1.std)); // private Bug? Intended? reported for you

Re: getProtection gives different result when member is accessed via getMember

2018-08-06 Thread Basile B. via Digitalmars-d-learn
On Sunday, 5 August 2018 at 01:48:08 UTC, Yuxuan Shui wrote: file1.d: import std.stdio; file2.d: import file1; pragma(msg, __traits(getProtection, __traits(getMember, m1, "std"))); // public pragma(msg, __traits(getProtection, m1.std)); // private Bug? Intended? It's a bug since in both

Re: -allinst and linker errors

2018-07-25 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 25 July 2018 at 15:56:50 UTC, Anonymouse wrote: I'm trying to build my project with -allinst, after reading the comments of issue 18026[1]. Manjaro/Arch 64-bit, dmd 2.081.1 and ldc 1.0.0. I get a wall of text with linker errors, both with dmd and ldc. Demangled excerpt: [...]

Re: DLL: (const char *paramNames[],size_t numParams)

2018-07-09 Thread Basile B. via Digitalmars-d-learn
On Monday, 9 July 2018 at 11:10:01 UTC, Basile B. wrote: On Monday, 9 July 2018 at 10:56:18 UTC, Andre Pany wrote: On Monday, 9 July 2018 at 10:38:54 UTC, Basile B. wrote: On Monday, 9 July 2018 at 10:33:03 UTC, Andre Pany wrote: Hi, no it's not correct i think, right translation would be

Re: DLL: (const char *paramNames[],size_t numParams)

2018-07-09 Thread Basile B. via Digitalmars-d-learn
On Monday, 9 July 2018 at 10:56:18 UTC, Andre Pany wrote: On Monday, 9 July 2018 at 10:38:54 UTC, Basile B. wrote: On Monday, 9 July 2018 at 10:33:03 UTC, Andre Pany wrote: Hi, no it's not correct i think, right translation would be extern(C) void GetParamNames(const char** paramNames,

Re: DLL: (const char *paramNames[],size_t numParams)

2018-07-09 Thread Basile B. via Digitalmars-d-learn
On Monday, 9 July 2018 at 10:33:03 UTC, Andre Pany wrote: Hi, I need to call a C function within a DLL which has following signature: void GetParamNames (const char *paramNames[], size_t numParams); The purpose of this function is to return a list of texts I defined in D: extern(C)

Re: Call different member functions on object sequence with a generic handler function?

2018-07-01 Thread Basile B. via Digitalmars-d-learn
On Sunday, 1 July 2018 at 06:55:35 UTC, Robert M. Münch wrote: On 2018-06-30 22:53:47 +, Jerry said: Btw this is pretty much std.algorithm.each import std.algorithm; void main() { auto cs = [ new C(), new C() ]; cs.each!(o => o.A()); }

Re: Call different member functions on object sequence with a generic handler function?

2018-06-30 Thread Basile B. via Digitalmars-d-learn
On Saturday, 30 June 2018 at 00:16:49 UTC, Basile B. wrote: On Friday, 29 June 2018 at 16:44:36 UTC, Robert M. Münch wrote: I hope this is understandable... I have: class C { void A(); void B(); void C(); } I'm iterating over a set of objects of class C like:

Re: Call different member functions on object sequence with a generic handler function?

2018-06-29 Thread Basile B. via Digitalmars-d-learn
On Friday, 29 June 2018 at 16:44:36 UTC, Robert M. Münch wrote: I hope this is understandable... I have: class C { void A(); void B(); void C(); } I'm iterating over a set of objects of class C like: foreach(obj; my_selected_objs){ ... } The iteration and code

Re: Getting Source code from complied code.

2018-06-28 Thread Basile B. via Digitalmars-d-learn
On Thursday, 28 June 2018 at 08:01:42 UTC, vino.B wrote: Hi All, Request your help on how to get the source code, i wrote a program named clean.d, complied it and by mistake deleted the source code(clean.d), so can we get back the source using the complied program(clean), if yes, can you

Re: Preferred Alias Declaration Style

2018-06-27 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 27 June 2018 at 15:27:09 UTC, Steven Schveighoffer wrote: On 6/27/18 6:22 AM, Vijay Nayar wrote: Does this mean that the `alias other aliasName;` syntax is preferred, or does it simply mean that this is a low priority issue that hasn't been addressed yet? IIRC, there was an

Re: Preferred Alias Declaration Style

2018-06-27 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 27 June 2018 at 14:29:18 UTC, Basile B. wrote: On Wednesday, 27 June 2018 at 14:23:25 UTC, Uknown wrote: On Wednesday, 27 June 2018 at 14:01:06 UTC, Basile B. wrote: [...] You can use this syntax for functions : `alias proto_identifier = void function();` Nah it's not the

Re: Preferred Alias Declaration Style

2018-06-27 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 27 June 2018 at 14:23:25 UTC, Uknown wrote: On Wednesday, 27 June 2018 at 14:01:06 UTC, Basile B. wrote: On Wednesday, 27 June 2018 at 12:25:26 UTC, Uknown wrote: On Wednesday, 27 June 2018 at 10:22:38 UTC, Vijay Nayar wrote: [...] aliasing a function type only works with the

Re: Preferred Alias Declaration Style

2018-06-27 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 27 June 2018 at 12:25:26 UTC, Uknown wrote: On Wednesday, 27 June 2018 at 10:22:38 UTC, Vijay Nayar wrote: Most of the documentation at https://dlang.org/spec/declaration.html#alias uses examples of the form: `alias aliasName = other;`, where `aliasName` becomes the new name to

Re: Undo in D

2018-06-23 Thread Basile B. via Digitalmars-d-learn
On Saturday, 23 June 2018 at 14:06:08 UTC, Basile B. wrote: On Saturday, 23 June 2018 at 01:58:31 UTC, DigitalDesigns wrote: Is there any idiomatic undo designs in D that give a more natural implementation than the standard techniques? - The "stuff to undo" can be a forward range ("save"

Re: Undo in D

2018-06-23 Thread Basile B. via Digitalmars-d-learn
On Saturday, 23 June 2018 at 01:58:31 UTC, DigitalDesigns wrote: Is there any idiomatic undo designs in D that give a more natural implementation than the standard techniques? - The "stuff to undo" can be a forward range ("save" primitive, + assignable from a stored state) - The manager can

Re: Redundant "g" flag for regex?

2018-06-23 Thread Basile B. via Digitalmars-d-learn
On Saturday, 23 June 2018 at 12:17:08 UTC, biocyberman wrote: I get the same output with or without "g" flag at line 6: https://run.dlang.io/is/9n7iz6 So I don't understand when I have to use "g" flag. My bet is that Regex results in D are lazy so "g" doesn't make sense in this context

Re: why explicitly use "flags" in regex does not work?

2018-06-23 Thread Basile B. via Digitalmars-d-learn
On Saturday, 23 June 2018 at 12:50:17 UTC, biocyberman wrote: On Saturday, 23 June 2018 at 12:20:10 UTC, biocyberman wrote: I got "Error: undefined identifier flags" in here: https://run.dlang.io/is/wquscz Removing "flags =" works. I kinda found an answer. It's a bit of a surprise anyway:

Re: Why std.array : array needs pure postblit?

2018-06-15 Thread Basile B. via Digitalmars-d-learn
On Friday, 15 June 2018 at 11:24:42 UTC, Basile B. wrote: On Friday, 15 June 2018 at 11:15:03 UTC, Andrea Fontana wrote: Check this code: https://run.dlang.io/is/PoluHI It won't work, because array appender requires a pure postblit. Why? Can we remove this limitation? Andrea Hello, i've

<    1   2   3   4   5   6   7   8   >