Re: Failed 'dub run' with 'Failed to invoke the compiler dmd'

2015-10-30 Thread Timoses via Digitalmars-d-learn
dub run -v Linking... dmd -of.dub/build/standalone-debug-posix.osx-x86_64-dmd_2068-4E2C9DFD17A7951AAA2F7856AB27FB45/vibelog .dub/build/standalone-debug-posix.osx-x86_64-dmd_2068-4E2C9DFD17A7951AAA2F7856AB27FB45/vibelog.o ../../.dub/packages/stringex-0.0.2/libstringex.a

Re: Failed 'dub run' with 'Failed to invoke the compiler dmd'

2015-10-30 Thread Timoses via Digitalmars-d-learn
On Saturday, 31 October 2015 at 03:38:57 UTC, Mike Parker wrote: How did you install DMD? I didn't : P. First hurdle taken. It now compiles. However, I get a linking error: Linking... ld: library not found for -levent clang: error: linker command failed with exit code 1 (use -v to see

Re: Failed 'dub run' with 'Failed to invoke the compiler dmd'

2015-10-30 Thread Timoses via Digitalmars-d-learn
On Saturday, 31 October 2015 at 04:00:18 UTC, Timoses wrote: Linking... ld: library not found for -levent clang: error: linker command failed with exit code 1 (use -v to see invocation) --- errorlevel 1 dmd failed with exit code 1. Seems to be fixed by editing dmd.conf (added

Failed 'dub run' with 'Failed to invoke the compiler dmd'

2015-10-30 Thread Timoses via Digitalmars-d-learn
Hey, just getting started with D. I wanted to try out Vibelog. However, when trying to run dub run I receive the error: Failed to invoke the compiler dmd to determine the build platform: /bin/sh: dmd: command not found I'm on OSX - El Capitan and installed dub over Homebrew. Bests,

Re: Failed 'dub run' with 'Failed to invoke the compiler dmd'

2015-10-31 Thread Timoses via Digitalmars-d-learn
On Saturday, 31 October 2015 at 06:13:27 UTC, Mike Parker wrote: DMD uses different linkers depending on the platform. For the compiler, -L means 'pass this command to the linker.' In this case, that just also happens to be -L, which is understood by ld (the system linker) as the flag to set

Re: Creating array of structs being used in C interface

2016-11-27 Thread Timoses via Digitalmars-d-learn
On Sunday, 27 November 2016 at 14:27:54 UTC, Adam D. Ruppe wrote: That's because int is zero initialized by default and thus doesn't need anything more than a call to zero memory function, and double isn't (it is NaN), so it gets an initializer data blob. If you make it = 0 it might work, but

Re: Creating array of structs being used in C interface

2016-11-27 Thread Timoses via Digitalmars-d-learn
On Sunday, 27 November 2016 at 13:22:36 UTC, Nicholas Wilson wrote: The missing symbol is the struct initialiser for neo4j_map_entry_t. Not sure why is not being generated (it should), possibly because of the union. That seems like a bug please report it. http://issues.dlang.org/ Thanks

Creating array of structs being used in C interface

2016-11-27 Thread Timoses via Digitalmars-d-learn
Hi there, I've got a problem interfacing to a C library. The following structs are used by the library's .d file that I've written. struct neo4j_map_entry_t { neo4j_value_t key; neo4j_value_t value; }; struct neo4j_value_t { uint8_t _vt_off; uint8_t

Access derived type in baseclass static function template

2017-08-02 Thread Timoses via Digitalmars-d-learn
Hey, wondering whether it's possible to access the derived type from a function template in the base class or interface. this T does not seem to be working, I guess because it's a static function and this does not exists?! interface I { static void test(this T)() {

Re: Access derived type in baseclass static function template

2017-08-03 Thread Timoses via Digitalmars-d-learn
On Wednesday, 2 August 2017 at 15:38:12 UTC, Steven Schveighoffer wrote: On 8/2/17 11:06 AM, Timoses wrote: On Wednesday, 2 August 2017 at 13:51:01 UTC, Steven Schveighoffer wrote: However, your original code has potential as an enhancement request, as the type is known at compile-time and

Re: Access derived type in baseclass static function template

2017-08-03 Thread Timoses via Digitalmars-d-learn
On Wednesday, 2 August 2017 at 12:07:46 UTC, Timoses wrote: Hey, wondering whether it's possible to access the derived type from a function template in the base class or interface. [...] Created an enhancement issue: https://issues.dlang.org/show_bug.cgi?id=17714

Check whether string value represents a type

2017-07-21 Thread Timoses via Digitalmars-d-learn
I'd love to check whether a string value is the name of a type at run-time. E.g.: string a = "int"; string b = "im no type"; assert( isStringType(a) ); assert( !isStringType(b) ); or struct TestStruct { int test; } string t = "TestStruct"; assert( isStringType(t) ); Is anything like

Re: Check whether string value represents a type

2017-07-24 Thread Timoses via Digitalmars-d-learn
On Friday, 21 July 2017 at 14:44:23 UTC, Steven Schveighoffer wrote: On 7/21/17 10:21 AM, Timoses wrote: I'd love to check whether a string value is the name of a type at run-time. E.g.: string a = "int"; string b = "im no type"; assert( isStringType(a) ); assert( !isStringType(b) ); or

Re: Check whether string value represents a type

2017-07-24 Thread Timoses via Digitalmars-d-learn
On Monday, 24 July 2017 at 07:08:56 UTC, Basile B. wrote: On Friday, 21 July 2017 at 14:21:37 UTC, Timoses wrote: I'd love to check whether a string value is the name of a type at run-time. [...] The goal is to identify whether a string represents a custom type within a package. I'm also

Re: Access derived type in baseclass static function template

2017-08-02 Thread Timoses via Digitalmars-d-learn
Thanks Arafel, the alias workaround might just be a nice way to put it. On Wednesday, 2 August 2017 at 13:51:01 UTC, Steven Schveighoffer wrote: What you are looking for is virtual static methods, and D doesn't have those. I don't know if there's a way to make it work with existing features.

Re: Access derived type in baseclass static function template

2017-08-02 Thread Timoses via Digitalmars-d-learn
On Wednesday, 2 August 2017 at 12:49:12 UTC, Steven Schveighoffer wrote: On 8/2/17 8:07 AM, Timoses wrote: Hey, wondering whether it's possible to access the derived type from a function template in the base class or interface. this T does not seem to be working, I guess because it's a

Re: "if" is not evaluated for fields of Class.tupleof

2017-05-23 Thread Timoses via Digitalmars-d-learn
The easiest way is probably casting: ``` import std.traits; import std.bitmanip; class Test { byte[4] marray; byte mbyte; } void main() { auto value = [0x12, 0x23, 0x34, 0x45, 0x56]; auto test = cast(Test*) value.ptr; } ```

"if" is not evaluated for fields of Class.tupleof

2017-05-19 Thread Timoses via Digitalmars-d-learn
Hey there, trying to read data into the fields of a class. This is what I got so far: ``` import std.traits; import std.bitmanip; class Test { byte[4] marray; byte mbyte; this(ubyte[] data) { auto fields = this.tupleof; foreach (field; fields) {

Use template functions within mixin

2017-06-06 Thread Timoses via Digitalmars-d-learn
Hey there, I'm wondering how I can use a template function within my mixin: ``` ubyte[] value = x[33, 3a,3f, d4]; foreach (type; TypeTuple!("int", "unsigned int", "byte")) { mixin(`if (value.length == type.sizeof)

Re: Use template functions within mixin

2017-06-07 Thread Timoses via Digitalmars-d-learn
On Tuesday, 6 June 2017 at 18:08:52 UTC, Ali Çehreli wrote: Just import modules at local scopes. Here is something that works: void displayinfo(T)(T v) { import std.stdio : writefln; writefln("%08x", v); } void foo() { import std.meta : AliasSeq; enum value =

Re: R.filter!(..).sort!(..)

2017-11-28 Thread Timoses via Digitalmars-d-learn
On Tuesday, 28 November 2017 at 14:04:40 UTC, Steven Schveighoffer wrote: Would be an awesome project to add to D. Oh yes, it sounds yummy..

Re: Range violation

2017-11-24 Thread Timoses via Digitalmars-d-learn
On Friday, 24 November 2017 at 09:59:13 UTC, Vino wrote: if (args.length < 1 || args.length > 2) { If args.length is 1 it will call string op = args[1]; However, args[1] accesses the second element. Due to above if statement args[1] can be called even though only args[0] exists.

opAssign for most struct assignment calls not executed

2017-11-23 Thread Timoses via Digitalmars-d-learn
What am I missing? import std.stdio; struct A { int value; A opAssign(A a) { writeln(" Assigning"); return this; // I know this makes little sense, just for illustration } } class B { A member; this(A a) { this.member = a; //

Re: Communicating between vibe.d's worker tasks

2017-11-23 Thread Timoses via Digitalmars-d-learn
On Thursday, 23 November 2017 at 10:15:26 UTC, Nordlöw wrote: I'm looking at http://vibed.org/api/vibe.core.concurrency/makeIsolated which is a great idea for safe inter-thread communication. Are there any more usage examples for vibe's worker tasks that show how to send instances of

Re: opAssign for most struct assignment calls not executed

2017-11-23 Thread Timoses via Digitalmars-d-learn
On Thursday, 23 November 2017 at 15:45:17 UTC, Rene Zwanenburg wrote: On Thursday, 23 November 2017 at 15:26:03 UTC, Timoses wrote: A aaa = a; That's initialization, not assignment, which is subtly different. It will call the postblit on aaa instead of opAssign. A postblit can be

Re: string version of array

2017-11-14 Thread Timoses via Digitalmars-d-learn
On Tuesday, 14 November 2017 at 14:00:54 UTC, Dr. Assembly wrote: On Tuesday, 14 November 2017 at 08:21:59 UTC, Tony wrote: On Tuesday, 14 November 2017 at 07:56:06 UTC, rikki cattermole wrote: Thanks. That flipped function calling syntax definitely takes some getting used to. if you

Re: Distinct "static" parent property contents for children

2017-11-09 Thread Timoses via Digitalmars-d-learn
On Wednesday, 8 November 2017 at 17:46:42 UTC, Adam D. Ruppe wrote: On Wednesday, 8 November 2017 at 17:38:27 UTC, Timoses wrote: Are there better options/ways of achieving this? What are you actually trying to achieve? What are you using these variables for? Well, I have the following

Re: Distinct "static" parent property contents for children

2017-11-09 Thread Timoses via Digitalmars-d-learn
On Wednesday, 8 November 2017 at 18:33:15 UTC, Steven Schveighoffer wrote: On 11/8/17 12:38 PM, Timoses wrote: Hey, wrapping my head around this atm.. [snip] so what you want is a static variable per subclass, but that the base class can access. What I would recommend is this: abstract

Re: Distinct "static" parent property contents for children

2017-11-09 Thread Timoses via Digitalmars-d-learn
On Thursday, 9 November 2017 at 14:34:10 UTC, Steven Schveighoffer wrote: On 11/9/17 7:34 AM, Timoses wrote: I suppose this is what Adam suggested, correct? Yes, more or less. It's just an actual implementation vs. a description in case it wasn't clear. [...] It's not much different

Distinct "static" parent property contents for children

2017-11-08 Thread Timoses via Digitalmars-d-learn
Hey, wrapping my head around this atm.. How would I achieve that children statically set a property of the parent so that the property is distinct between different children? The following is *bs*, but kind of illustrates what I'd "like": class Base { int x; } class A : Base {

Re: Distinct "static" parent property contents for children

2017-11-08 Thread Timoses via Digitalmars-d-learn
On Wednesday, 8 November 2017 at 17:38:27 UTC, Timoses wrote: Option 2: class Base { int x;} class A : Base { this() { x = 1; } } class B : Base { this() { x = 2; } } Con: Well, the downside is that every instance of A and B allocates space for x although only one allocation would be

Re: using Unsized Arrays in Structures from d?

2018-05-04 Thread Timoses via Digitalmars-d-learn
On Friday, 4 May 2018 at 13:27:03 UTC, NewUser wrote: Hi Timoses, The structure is being returned from c and I'd like use it from d. What you have work perfectly when assigning from d. Regards, NewUser Then you probably need some `extern(C)` statement introducing the C function and the

Re: `recursive template expansion` error msg isn't informative

2018-05-07 Thread Timoses via Digitalmars-d-learn
On Monday, 7 May 2018 at 10:28:14 UTC, drug wrote: I get the error like: ``` ./foo/bar/baz/builder.d(57,23): Error: template instance `staticMap!(DebugTypeMapper, BaseDebuggerTypes)` recursive template expansion ``` That's all. It doesn's print instantiations stack so I can't track back the

Re: Template to retrieve compile-time enum member from run-time enum member?

2018-04-27 Thread Timoses via Digitalmars-d-learn
On Thursday, 26 April 2018 at 16:46:11 UTC, Simen Kjærås wrote: The only step you're missing is the template needs to be instantiated inside the static foreach, like this: auto instantiateWith(alias Fn, T)(T x) if (is(T == enum)) { import std.traits : EnumMembers; switch (x) {

Re: Template to retrieve compile-time enum member from run-time enum member?

2018-04-27 Thread Timoses via Digitalmars-d-learn
Bumped across another problem : / ``` import std.stdio; enum menum { A, B, C } void main() { foo(menum.A); } void foo(menum e) { writeln(instantiateWith!Temp(e)); } auto instantiateWith(alias Fn, T)(T x) if (is(T == enum)) { switch (x) { import std.traits :

Re: Template to retrieve compile-time enum member from run-time enum member?

2018-04-27 Thread Timoses via Digitalmars-d-learn
On Friday, 27 April 2018 at 13:39:22 UTC, Simen Kjærås wrote: That's an unfortunate error message. The problem is TempStruct is defined inside the Temp template. In the same way that struct Foo(T) {} is different for Foo!int and Foo!string, TempStruct is a different type for Temp!(menum.A) and

Re: using Unsized Arrays in Structures from d?

2018-05-04 Thread Timoses via Digitalmars-d-learn
On Friday, 4 May 2018 at 13:02:08 UTC, NewUser wrote: tried defining items[] as both "Item[] items" and "Item* items" in d, it compiles okay but gives an error when trying to access it. You were on the right track. D array notation is: [] ; For me this works: ``` struct Item { int id; };

Re: C++ / Wrong function signature generated for reference parameter

2018-05-04 Thread Timoses via Digitalmars-d-learn
On Thursday, 3 May 2018 at 11:29:59 UTC, Robert M. Münch wrote: Not sure I understand this too. This is now what I get: DMD: public: unsigned int __cdecl b2d::Context2D::_begin(class b2d::Image & __ptr64,class b2d::Context2D::InitParams const * __ptr64 const) __ptr64 LIB: public: unsigned int

Re: Storing temp for later use with ranges

2018-06-16 Thread Timoses via Digitalmars-d-learn
On Saturday, 16 June 2018 at 01:53:15 UTC, DigitalDesigns wrote: Does ranges have the ability to store a temp value in a "range like way" that can be used later? The idea is to avoid having to create temp variables. A sort of range with "memory" I believe that if the range is a forward

Re: Class qualifier vs struct qualifier

2018-06-16 Thread Timoses via Digitalmars-d-learn
On Thursday, 14 June 2018 at 17:07:09 UTC, Jonathan M Davis wrote: Sure, it would save you a little bit of typing when you do something like auto foo = new Foo; if makes it immutable for you, but it's at the cost of code clarity. Why should it even? Isn't immutable class C {

Re: foreach DFS/BFS for tree data-structure?

2018-06-16 Thread Timoses via Digitalmars-d-learn
On Thursday, 14 June 2018 at 11:31:50 UTC, Robert M. Münch wrote: I have a simple tree C data-structure that looks like this: node { node parent: vector[node] children; } I would like to create two foreach algorthims, one follwing the breadth first search pattern and one the

Re: scope(success) lowered to try-catch ?

2018-06-17 Thread Timoses via Digitalmars-d-learn
On Sunday, 17 June 2018 at 10:58:29 UTC, Cauterite wrote: Hello, I'm not sure whether I'm missing something obvious here, but is there a reason for scope(success) being lowered to a try-catch statement? I would have expected only scope(exit) and scope(failure) to actually interact with

Re: determining if array element is null

2018-06-05 Thread Timoses via Digitalmars-d-learn
On Saturday, 2 June 2018 at 18:10:38 UTC, eastanon wrote: Does D array implementation support an array of null values? int a[4] = null; But I ran into a type error while checking if a[i] is null foreach(i; 0..3){ if(i == null){ writeln("it is null"); } } } How do you set fixed size

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

2018-07-01 Thread Timoses via Digitalmars-d-learn
On Sunday, 1 July 2018 at 06:55:35 UTC, Robert M. Münch wrote: The looping needs to be done in the handler because there are two loops running one after the other and the range to loop over is detected in the handler too. Otherwise a lot of code duplication would happen. Maybe an

Re: template alias that includes a parameter

2018-07-01 Thread Timoses via Digitalmars-d-learn
On Sunday, 1 July 2018 at 01:48:15 UTC, Simen Kjærås wrote: I'd send you straight to std.meta.ApplyLeft, but it seems to do the wrong thing here, in that it doesn't handle IFTI. This thing does: void fooImpl(int n, T)(const T line) { } unittest { alias fun = applyLeft!(fooImpl, 3);

Re: Function Template for Dynamic Parameter

2018-07-01 Thread Timoses via Digitalmars-d-learn
On Sunday, 1 July 2018 at 09:46:32 UTC, vino.B wrote: All, Request your help, the D document states that "Template functions are useful for avoiding code duplication - instead of writing several copies of a function, each with a different parameter type, a single function template can be

Re: Function Template for Dynamic Parameter

2018-07-01 Thread Timoses via Digitalmars-d-learn
On Sunday, 1 July 2018 at 11:19:50 UTC, vino.B wrote: On Sunday, 1 July 2018 at 09:55:34 UTC, Timoses wrote:> Hi Timoses, Thank you very much, can you help me on how to rewrite the below using Variadic template Passing function as a parameter to another function: void ptFun(T)(T

Re: Function Template for Dynamic Parameter

2018-07-01 Thread Timoses via Digitalmars-d-learn
On Sunday, 1 July 2018 at 11:58:30 UTC, vino.B wrote: On Sunday, 1 July 2018 at 11:52:19 UTC, Alex wrote: NewType.d(19): Error: function declaration without return type. (Note that constructors are always named this) [...] auto coCleanFiles(T ...)(T args) { auto dFiles =

Re: template alias that includes a parameter

2018-07-01 Thread Timoses via Digitalmars-d-learn
On Sunday, 1 July 2018 at 11:55:15 UTC, Simen Kjærås wrote: On Sunday, 1 July 2018 at 09:46:55 UTC, Timoses wrote: Would be nice if std.meta.ApplyLeft did the job here.. Is there no way of achieving that? [snip] Would have to find a way to determine whether Template would resolve to a

Re: template alias that includes a parameter

2018-07-01 Thread Timoses via Digitalmars-d-learn
On Sunday, 1 July 2018 at 13:01:20 UTC, Timoses wrote: Aw, okay, then that won't work. Still, this looks like it should work: void foo(F, T)(T param) { writeln("Called with type: ", T.stringof); } alias tfoo = ApplyLeft!(foo, int); tfoo!string("hi"); // tfoo("hi"); // Error

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

2018-06-29 Thread Timoses via Digitalmars-d-learn
On Friday, 29 June 2018 at 20:08:56 UTC, Robert M. Münch wrote: On 2018-06-29 18:05:00 +, Ali ‡ehreli said: On 06/29/2018 09:44 AM, Robert M. Münch wrote: void handler(alias func)(C[] cs) { foreach (c; cs) { func(c); } } Is it possible to make C[] a template type so

Re: Issues with undefined symbols when using Vibe on Windows

2018-06-29 Thread Timoses via Digitalmars-d-learn
On Friday, 29 June 2018 at 19:25:42 UTC, Chris M. wrote: This doesn't appear to specifically be a Vibe issue, just noticing this error when I use eventcore from it (trying to use async). C:\dmd2\windows\bin\lld-link.exe: warning: eventcore.lib(sockets_101f_952.obj): undefined symbol:

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

2018-06-29 Thread Timoses 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: Call different member functions on object sequence with a generic handler function?

2018-06-29 Thread Timoses via Digitalmars-d-learn
On Friday, 29 June 2018 at 20:28:55 UTC, Timoses wrote: On Friday, 29 June 2018 at 16:44:36 UTC, Robert M. Münch wrote: Trying to fiddle around a bit with delegates.. But why is the context for delegates not working for classes?? Aw.. Class = reference type so class A { } struct B { } void

Re: anyway to pass the context of an inner type to a template so it can be constructed?

2018-06-27 Thread Timoses via Digitalmars-d-learn
On Wednesday, 27 June 2018 at 12:02:10 UTC, aliak wrote: This currently fails unless you mark the class as static: auto construct(T)() { return new T; } void main() { class C {} auto s = construct!C; } So wondering if there's anything that can be done to get the above working?

Re: Making sense of recursion

2018-06-26 Thread Timoses via Digitalmars-d-learn
On Monday, 25 June 2018 at 17:45:01 UTC, zbr wrote: Hi, this question is not specifically D related but I'll just ask anyway. Consider the following snippet: void mergeSort(int[] arr, int l, int r) { if (l < r) // 1 { int m = l+(r-l)/2;// 2

Re: Is HibernateD dead?

2018-06-23 Thread Timoses via Digitalmars-d-learn
On Thursday, 3 May 2018 at 10:27:47 UTC, Pasqui23 wrote: Last commit on https://github.com/buggins/hibernated was almost a year ago So what is the status of HibernateD?Should I use it if I need an ORM? Or would I risk unpatched security risks? Okay... wall of text. TLDR: project definition /

Re: template alias that includes a parameter

2018-06-30 Thread Timoses via Digitalmars-d-learn
On Saturday, 30 June 2018 at 21:11:54 UTC, Anonymouse wrote: I have a template that I want to provide easy aliases for, where the aliases includes (partially applies?) a template parameter. void fooImpl(char token, T)(const T line) { // ... } alias quoteFoo(T) = fooImpl!('"', T);

Template to retrieve compile-time enum member from run-time enum member?

2018-04-26 Thread Timoses via Digitalmars-d-learn
The following should depict what I'm trying to achieve: ``` import std.stdio; enum menum { A, B, C } void main() { foo(menum.B); } void foo(menum e) { // Not possible // run time variable 'e' in conjunction with template 'Temp' writeln(Temp!(GetMenum(e))); } static int i

Re: Interfacing with C++ Class named Object

2018-05-01 Thread Timoses via Digitalmars-d-learn
On Tuesday, 1 May 2018 at 15:24:09 UTC, Robert M. Münch wrote: Hi, I'm mostly doing simple C-API wrappers around C++ code to access thigns from D. However, I wanted to try how far I can come using C++ directly. I have the following C++ code in namespace N: class Image : public Object {

cast const pointer to non-const and change value yields neither result nor error

2018-04-30 Thread Timoses via Digitalmars-d-learn
Hey, reading through https://dlang.org/articles/const-faq.html and experimenting a bit: ``` immutable int i = 3; const(int)* p = int* q = cast(int*)p; assert(q == p && p == ); writeln(i); // 3 *q = 1; // Why does this have no effect at all? No error no

Re: Template to retrieve compile-time enum member from run-time enum member?

2018-04-28 Thread Timoses via Digitalmars-d-learn
On Friday, 27 April 2018 at 14:33:36 UTC, Alex wrote: On Friday, 27 April 2018 at 13:43:47 UTC, Timoses wrote: `instantiateWith` gets called in three variations (menum.A, menum.B and menum.C). This causes instantiateWith to return TempStruct for each case of Temp... However, I was under

rdmd main.d leads to Segmentation fault

2018-01-26 Thread Timoses via Digitalmars-d-learn
Hey, simple hello world crashes with segfault: import std.stdio; void main() { writeln("hi"); } $ rdmd main.d Segmentation fault Same problem with a vibe.d project. Just set up this VirtualBox $ dmd --version DMD32 D Compiler v2.078.1 $ rdmd --version rdmd build 20180121 ... $ uname -a

Re: rdmd main.d leads to Segmentation fault

2018-01-29 Thread Timoses via Digitalmars-d-learn
On Monday, 29 January 2018 at 15:03:48 UTC, Stefan Koch wrote: On Friday, 26 January 2018 at 22:40:29 UTC, Timoses wrote: Hey, simple hello world crashes with segfault: [...] I can not reproduce this. Well, the cause is not yet uncovered, I suppose... Any more ideas?

Re: rdmd main.d leads to Segmentation fault

2018-01-30 Thread Timoses via Digitalmars-d-learn
On Tuesday, 30 January 2018 at 14:08:35 UTC, Kagamin wrote: On Sunday, 28 January 2018 at 22:02:11 UTC, Timoses wrote: How would I do that? https://forum.dlang.org/post/mailman.39.1510078013.9493.digitalmars-d-...@puremagic.com like this Thanks! I did $ gdb main $ (gdb) set logging on $

Re: rdmd main.d leads to Segmentation fault

2018-01-28 Thread Timoses via Digitalmars-d-learn
On Saturday, 27 January 2018 at 01:23:44 UTC, Fra Mecca wrote: On Friday, 26 January 2018 at 22:40:29 UTC, Timoses wrote: Hey, simple hello world crashes with segfault: [...] Where did you get the D toolchain? Got it from here: http://d-apt.sourceforge.net/ with $ apt-get install

Re: rdmd main.d leads to Segmentation fault

2018-01-28 Thread Timoses via Digitalmars-d-learn
On Saturday, 27 January 2018 at 21:04:07 UTC, Kagamin wrote: On Friday, 26 January 2018 at 22:40:29 UTC, Timoses wrote: Program received signal SIGSEGV, Segmentation fault. 0x00432e04 in _d_dso_registry () (gdb) bt #0 0x00432e04 in _d_dso_registry () #1 0x00431c63 in ?? () #2 0x0045c08b in

Re: rdmd main.d leads to Segmentation fault

2018-01-31 Thread Timoses via Digitalmars-d-learn
On Wednesday, 31 January 2018 at 08:40:26 UTC, Kagamin wrote: On Tuesday, 30 January 2018 at 16:56:28 UTC, Timoses wrote: Output: https://pastebin.com/raw/SSx0P1Av Helps? Looks like TLS is not initialized. And I would need to do what about it? Sorry, I'm not familiar with assembly code

Re: rdmd main.d leads to Segmentation fault

2018-02-04 Thread Timoses via Digitalmars-d-learn
On Thursday, 1 February 2018 at 09:01:34 UTC, Kagamin wrote: On Wednesday, 31 January 2018 at 16:59:15 UTC, Timoses wrote: And I would need to do what about it? Sorry, I'm not familiar with assembly code stuff in detail. You can try to see if it works on another distro or version. It does

Re: Convert path to file system path on windows

2018-06-21 Thread Timoses via Digitalmars-d-learn
On Thursday, 21 June 2018 at 18:46:05 UTC, Dr.No wrote: How can I do that with D? In C# you can do that: var filename = @"C:\path\to\my\file.txt"; var file = new Uri(filename).AbsoluteUri; // file is "file:///C:/path/to/my/file.txt" How can I do that in D? I don't know of a specific

Re: hasUDA with this

2018-07-26 Thread Timoses via Digitalmars-d-learn
On Wednesday, 25 July 2018 at 21:17:38 UTC, jmh530 wrote: On Friday, 20 July 2018 at 18:24:11 UTC, Timoses wrote: [snip] It works in module scope https://run.dlang.io/is/OQKYag I don't know why though... This was reported in 2013. IMO, it should be mentioned in the spec if they don't plan

Re: Why does templated interface function return something different than final function?

2018-08-08 Thread Timoses via Digitalmars-d-learn
On Monday, 6 August 2018 at 14:27:01 UTC, Timoses wrote: On Thursday, 2 August 2018 at 20:35:57 UTC, Steven Schveighoffer wrote: Looking at the AST, it appears that toImpl doesn't recognize what inout(iface) is: toImpl!(string, inout(iface)) { @system string toImpl(ref inout(iface)

Re: Why does templated interface function return something different than final function?

2018-08-06 Thread Timoses via Digitalmars-d-learn
On Thursday, 2 August 2018 at 20:35:57 UTC, Steven Schveighoffer wrote: Looking at the AST, it appears that toImpl doesn't recognize what inout(iface) is: toImpl!(string, inout(iface)) { @system string toImpl(ref inout(iface) value) { import std.array :

Re: How to declare static compile-time assoc array inside struct?

2018-08-13 Thread Timoses via Digitalmars-d-learn
On Monday, 13 August 2018 at 13:21:45 UTC, Andrey wrote: On Monday, 13 August 2018 at 11:53:06 UTC, rikki cattermole wrote: You must use a module constructor to initialize it. Tried this: static this() { Test.DESCRIPTION = [Test.Type.One: "One!", Test.Type.Two: "It's Two...",

Re: Importing struct

2018-08-13 Thread Timoses via Digitalmars-d-learn
On Monday, 13 August 2018 at 14:16:47 UTC, Mike Parker wrote: On Monday, 13 August 2018 at 13:09:24 UTC, Andrey wrote: On Monday, 13 August 2018 at 13:05:28 UTC, evilrat wrote: however the best option is simply avoid naming anything with same name as module. Hmm, I thought that name of class

Re: vibe.d: Finding out if currently in webinterface request

2018-08-10 Thread Timoses via Digitalmars-d-learn
On Thursday, 9 August 2018 at 21:59:24 UTC, Johannes Loher wrote: I already posted this in the vibe.d forums (https://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/thread/58891/), but it seems, there is not a lot of activity over there, so I am cross posting this here: [...] Do

Re: How do you put log calls in constructors when they may be created in a static context?

2018-08-10 Thread Timoses via Digitalmars-d-learn
On Wednesday, 8 August 2018 at 21:54:34 UTC, aliak wrote: I'm trying to debug stuff, so I want to add verbose logging struct S(T) { this() { writeln("created S(T) with properties and ID"); } } static a = S!int(); // bah I guess users can call this code from any context, but when i'd

Re: Concat enum of strings into one string

2018-08-14 Thread Timoses via Digitalmars-d-learn
On Tuesday, 14 August 2018 at 14:37:33 UTC, Andrey wrote: Thank you. Hmm, I thought that standard library already has this stuff. There might be more elegant solutions and I'd be happy to see some more. I'm always just digging into std.traits [1] and Traits spec part [2] and try to fumble

Re: Concat enum of strings into one string

2018-08-14 Thread Timoses via Digitalmars-d-learn
On Tuesday, 14 August 2018 at 13:42:04 UTC, Andrey wrote: Hello, I have a enum: enum Type : string { One = "Q1", Two = "W2", Three = "R3" } I want to concat it in compile-time: enum result = doConcat!Type(); And get this result: writeln(result); // output: "Q1 W2 R3" Delimiter

Re: Member function passed through template alias only requiring `this` in certain conditions?

2018-07-19 Thread Timoses via Digitalmars-d-learn
On Thursday, 19 July 2018 at 22:16:22 UTC, Ali Çehreli wrote: On 07/19/2018 08:12 AM, Emma wrote: > [...] > If I try to compile it, dmd complains, which I guess makes sense: > > --- > Error: need this for bar of type void() > Error: need this for baz of type void() > --- > > [...] I think it's

Re: hasUDA with this

2018-07-20 Thread Timoses via Digitalmars-d-learn
On Thursday, 19 July 2018 at 19:18:43 UTC, jmh530 wrote: I wanted to create a struct with a member function whose behavior was different depending on whether the struct instance had a particular UDA. However, it seems like hasUDA doesn't seem to produce the result I would have expected here.

Re: hasUDA with this

2018-07-20 Thread Timoses via Digitalmars-d-learn
On Friday, 20 July 2018 at 16:53:12 UTC, jmh530 wrote: Hmm, on that part about the attributes copying their values, I suppose it would be sufficient if I could apply the attributes to a group of declarations. However, it didn't seem to work properly for me with UDAs, and I noticed that even

Re: Is there any tool that will auto publish my changes.

2018-07-16 Thread Timoses via Digitalmars-d-learn
On Sunday, 15 July 2018 at 00:25:22 UTC, Venkat wrote: I am writing a simple vibe.d app. The following is what I do right now. - I make changes. - build - Restart the server. Is there any tool that will auto publish my changes as I save them ? I am using Visual Studio Code. Thanks Venkat

Re: Find out druntime/import and phobos folder on Linux

2018-07-15 Thread Timoses via Digitalmars-d-learn
On Saturday, 14 July 2018 at 19:04:01 UTC, Andre Pany wrote: On Saturday, 14 July 2018 at 19:00:56 UTC, Anonymouse wrote: On Saturday, 14 July 2018 at 17:19:20 UTC, Andre Pany wrote: Is there a way to find out both paths based on the dmd executable folder? What I found out so far, these

Re: trait to get the body code of a function?

2018-07-24 Thread Timoses via Digitalmars-d-learn
On Tuesday, 24 July 2018 at 04:43:33 UTC, Guillaume Lathoud wrote: Hello, __traits and std.traits already offer access to function information like input parameters, e.g. in std.traits: ParameterIdentifierTuple ParameterStorageClassTuple Even if that might sound strange, is there a compile

Re: How to avoid inout type constructor with Optional type wrapper undoing string type

2018-07-24 Thread Timoses via Digitalmars-d-learn
On Monday, 23 July 2018 at 18:39:59 UTC, aliak wrote: Hi, I'm playing around with an Optional wrapper type. It stores a type T and a bool that defines whether a value is defined or not: struct Optional(T) { T value; bool defined = false; this(U : T)(auto ref inout(U) value) inout {

Re: Implicit conversion of struct with methods to immutable in pure function fails

2018-07-19 Thread Timoses via Digitalmars-d-learn
On Thursday, 19 July 2018 at 06:35:36 UTC, Simen Kjærås wrote: On Wednesday, 18 July 2018 at 11:28:54 UTC, Timoses wrote: But why is a context pointer a problem? Is it problematic because the context pointer to the main scope can not guarantee `immutable`? E.g. if I happened to use data from

Re: @safe - why does this compile?

2018-07-14 Thread Timoses via Digitalmars-d-learn
On Friday, 13 July 2018 at 22:17:59 UTC, Dukc wrote: On Friday, 13 July 2018 at 13:52:27 UTC, Timoses wrote: I suppose this is another good example of how casting can be dangerous? E.g. also: immutable int i = 3; int* j = cast(int*) assert(i == 3); *j = 4; assert(j ==

Re: Orange not working?

2018-07-14 Thread Timoses via Digitalmars-d-learn
On Friday, 13 July 2018 at 21:38:18 UTC, JN wrote: I'm curious, are the tests in any way OS specific? I see the tests are passing, but trying the latest DMD on Windows and orange v2.0.0, when I add "@nonSerialized" to a struct member, I get this: C:\Users\jacek\Desktop\test_orange>dub run

Implicit conversion of struct with methods to immutable in pure function fails

2018-07-16 Thread Timoses via Digitalmars-d-learn
Why does this fail? struct F { int i; ushort _x; void x(ushort v) pure {_x = v;} ushort x() const { return _x; } } immutable F f1 = () pure { F lf = F(); return lf; }(); // Error: cannot implicitly convert expression

Re: Implicit conversion of struct with methods to immutable in pure function fails

2018-07-16 Thread Timoses via Digitalmars-d-learn
On Monday, 16 July 2018 at 12:00:57 UTC, Simen Kjærås wrote: On Monday, 16 July 2018 at 11:43:03 UTC, Timoses wrote: Why does this fail? It doesn't. Not using DMD 2.081.1 under Windows, at least. I tried adding a bitfield since you mentioned it, but it compiles nicely for me. Which version

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

2018-07-16 Thread Timoses via Digitalmars-d-learn
On Monday, 16 July 2018 at 11:31:32 UTC, Seb wrote: On Monday, 16 July 2018 at 11:12:20 UTC, Dukc wrote: On Saturday, 14 July 2018 at 03:08:50 UTC, Vladimir Panteleev wrote: I'll follow up with Alawain. Regardless, dscripten-tools borrows very little from the redistributable parts of

Re: Call method with Variant array as parameters

2018-07-14 Thread Timoses via Digitalmars-d-learn
On Saturday, 14 July 2018 at 11:08:21 UTC, Andre Pany wrote: Hi, I have a class with methods and I want to call a method by using a variant array. The length of the array and the types exactly fits the method signature. In the last line of main you see the coding which should be generated.

Re: How to avoid inout type constructor with Optional type wrapper undoing string type

2018-07-25 Thread Timoses via Digitalmars-d-learn
On Tuesday, 24 July 2018 at 14:11:51 UTC, Ali Çehreli wrote: On 07/24/2018 02:47 AM, Timoses wrote: > Why does this fail while it works when replacing T with U in struct > W(T)?? It's so odd. Both T and U seem to resolve to "string". > > struct W(T) { > const T value; >

Re: How to get an inout constructor working with a template wrapper

2018-07-23 Thread Timoses via Digitalmars-d-learn
On Monday, 23 July 2018 at 12:02:58 UTC, aliak wrote: Thank you Ali! That helped :) I've gotten most of it sorted out now, and the factory wrap is definitely the way to go, it also turned out that inout(T) and inout T (so inout without parens) was surprisingly different (maybe it's a bug? -

Re: Implicit conversion of struct with methods to immutable in pure function fails

2018-07-18 Thread Timoses via Digitalmars-d-learn
On Tuesday, 17 July 2018 at 06:24:12 UTC, Simen Kjærås wrote: That makes sense. The problem is F has a context pointer to the main() block, since it's a non-static struct with methods inside a block. It doesn't actually use the context pointer for anything, so it possibly shouldn't have one,

Re: Why does templated interface function return something different than final function?

2018-07-18 Thread Timoses via Digitalmars-d-learn
On Wednesday, 18 July 2018 at 11:09:12 UTC, Timoses wrote: Why is the interface templated function not also returning the class C toString return value "in C"?? interface iface { void toString(scope void delegate(const(char)[]) sink) const;

Why does templated interface function return something different than final function?

2018-07-18 Thread Timoses via Digitalmars-d-learn
Why is the interface templated function not also returning the class C toString return value "in C"?? interface iface { void toString(scope void delegate(const(char)[]) sink) const; final string convert() inout {

Re: Mutable ForwardRange save() method not callable using const object

2018-09-04 Thread Timoses via Digitalmars-d-learn
On Tuesday, 4 September 2018 at 14:26:44 UTC, Steven Schveighoffer wrote: [...] As general advice, I wouldn't expect const to work well with Ranges anyway -- const ranges are useless (you can't iterate them). So not much code is expecting to handle const, including the wrappers that Phobos

Re: Struct immutable data and dict

2018-09-04 Thread Timoses via Digitalmars-d-learn
On Tuesday, 4 September 2018 at 12:27:47 UTC, nkm1 wrote: I also had this problem recently. I think aa.require() should allow to add immutables (feature request). Anyway, my workaround was along the lines of: final class AA(Key, Value) { Value[] _storage; size_t[Key] _aa; void

  1   2   >