Re: Creating Struct for an output of a program.

2018-01-09 Thread Mengu via Digitalmars-d-learn
On Tuesday, 9 January 2018 at 07:57:19 UTC, Vino wrote: Hi All, Request your help on how to create a struct with the output of the below program. Program: import std.algorithm: all, map, filter; import std.stdio: File, writeln; import std.typecons: Tuple, tuple; import std.container.array;

Re: C++ Interop

2018-01-06 Thread Mengu via Digitalmars-d-learn
On Friday, 5 January 2018 at 13:02:12 UTC, qznc wrote: I'm exploring [0] C++ interop after watching Walter's presentation [1]. I hit a block with classes as template parameters. This means vector works, but vector does not. D seems to map vector!Foo to vector. Likewise shared_ptr is a

Re: How do you safely deal with range.front?

2017-12-30 Thread Mengu via Digitalmars-d-learn
On Saturday, 30 December 2017 at 19:00:07 UTC, aliak wrote: On Friday, 29 December 2017 at 20:47:44 UTC, Dukc wrote: [...] Hmm, interesting. Not sure that's what I'm looking for but I like it anyway :) I'm more looking to deal with situations like this: Instead of this: auto result =

Re: structs inheriting from and implementing interfaces

2017-12-29 Thread Mengu via Digitalmars-d-learn
On Friday, 29 December 2017 at 13:08:38 UTC, rikki cattermole wrote: On 29/12/2017 12:59 PM, rjframe wrote: On Fri, 29 Dec 2017 12:39:25 +, Nicholas Wilson wrote: [...] I've actually thought about doing this to get rid of a bunch of if qualifiers in my function declarations. `static

Re: How do I set a class member value by its name in a string?

2017-12-28 Thread Mengu via Digitalmars-d-learn
On Wednesday, 27 December 2017 at 23:47:14 UTC, Biotronic wrote: [...] much, much better. thanks biotronic.

Re: How do I set a class member value by its name in a string?

2017-12-27 Thread Mengu via Digitalmars-d-learn
On Wednesday, 27 December 2017 at 21:39:49 UTC, Mengu wrote: On Wednesday, 27 December 2017 at 20:54:17 UTC, bitwise wrote: [...] there's also a simple workaround for fields with the same type: https://run.dlang.io/is/dsFajq import std.stdio; struct S { int x; int y; } auto

Re: How do I set a class member value by its name in a string?

2017-12-27 Thread Mengu via Digitalmars-d-learn
On Wednesday, 27 December 2017 at 20:54:17 UTC, bitwise wrote: On Wednesday, 27 December 2017 at 20:04:29 UTC, Marc wrote: I'd like to set the members of a class by its name at runtime, I would do something like this: __traits(getMember, myClass, name) = value; but since name is only know

Re: partial application for templates

2017-12-26 Thread Mengu via Digitalmars-d-learn
On Monday, 25 December 2017 at 22:58:50 UTC, David Nadlinger wrote: On Monday, 25 December 2017 at 20:39:52 UTC, Mengu wrote: is partially applying templates possible? Check out std.meta.Apply{Left, Right}. — David thanks a lot mr. smith & david.

Re: Can I use memoize with a non-static struct method?

2017-12-26 Thread Mengu via Digitalmars-d-learn
On Tuesday, 26 December 2017 at 00:47:14 UTC, Marc wrote: something like this: struct S { // variables... string doGen(int n) { return ""; } alias gen = memoize!doGen; } The error I got is: Error: need 'this' for 'doGen' of type 'string(int n)' I can't make doGen static because it

partial application for templates

2017-12-25 Thread Mengu via Digitalmars-d-learn
is partially applying templates possible?

Re: Define enum value at compile time via compiler argument?

2017-12-25 Thread Mengu via Digitalmars-d-learn
On Monday, 25 December 2017 at 16:13:48 UTC, Thomas Mader wrote: Hello, I would like to set the path to a directory at compile time but it doesn't seem to be possible yet. I tried it with a -version=CustomPath argument and inside the version statement in the code I tried to read the value

Re: Does to!(string)(char[]) do any memory allocation on conversion?

2017-12-25 Thread Mengu via Digitalmars-d-learn
On Monday, 25 December 2017 at 14:12:32 UTC, Marc wrote: Does to!(string)(char[]) do any memory allocation on conversion or is this similar to a cast or what else? yes, it is allocating memory. you can test such cases with @nogc [0]. you can get a char[] via .dup of a string and then you

Re: Converting array in to aliased tuple type.

2017-12-25 Thread Mengu via Digitalmars-d-learn
On Monday, 25 December 2017 at 12:03:32 UTC, aliak wrote: Hi, been looking for a way to convert an array to a tuple, but can't seem to find one. Is there one? Looking for something like: alias Point = Tuple!(int, "x", int, "y"); enum data = "1,2:8,9"; auto points = data .split(':')

Re: One liner for creating an array filled by a factory method

2017-12-23 Thread Mengu via Digitalmars-d-learn
On Saturday, 23 December 2017 at 08:57:18 UTC, kerdemdemir wrote: On Friday, 22 December 2017 at 23:33:55 UTC, Mengu wrote: On Thursday, 21 December 2017 at 21:11:58 UTC, Steven Schveighoffer wrote: On 12/21/17 4:00 PM, kerdemdemir wrote: I have a case like : http://rextester.com/NFS28102 I

Re: One liner for creating an array filled by a factory method

2017-12-22 Thread Mengu via Digitalmars-d-learn
On Thursday, 21 December 2017 at 21:11:58 UTC, Steven Schveighoffer wrote: On 12/21/17 4:00 PM, kerdemdemir wrote: I have a case like : http://rextester.com/NFS28102 I have a factory method, I am creating some instances given some enums. My question is about : void PushIntoVector(

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

2017-12-22 Thread Mengu via Digitalmars-d-learn
On Thursday, 21 December 2017 at 18:45:27 UTC, Adam D. Ruppe wrote: On Thursday, 21 December 2017 at 18:20:19 UTC, H. S. Teoh wrote: When the scoped destruction of structs isn't an option, RefCounted!T seems to be a less evil alternative than an unreliable class dtor. :-/ Alas, RefCounted

Re: Converting member variables to strings with using reflection from base class

2017-12-22 Thread Mengu via Digitalmars-d-learn
On Friday, 22 December 2017 at 22:09:05 UTC, H. S. Teoh wrote: On Fri, Dec 22, 2017 at 09:13:31PM +, kerdemdemir via Digitalmars-d-learn wrote: I want to make a logging function for member variables by using reflection. [...] class B { void Log() { auto a =

Re: alias to struct method

2017-12-22 Thread Mengu via Digitalmars-d-learn
On Friday, 22 December 2017 at 17:53:34 UTC, Marc wrote: How can I create a alias to a struct method? struct S { string doSomething(int n) { return ""; } } I'd like to do something like this (imaginary code): alias doSomething = S.doSomething; then call it by doSomething(3) I got the

Re: why @property cannot be pass as ref ?

2017-12-20 Thread Mengu via Digitalmars-d-learn
On Wednesday, 20 December 2017 at 18:04:57 UTC, Ali Çehreli wrote: On 12/20/2017 07:02 AM, ChangLong wrote: > [...] is not > [...] The problem is not with opAssign but with left(), which returns an rvalue. It's by design that rvalues cannot be bound to references in D. [...] was just

Re: Can I run this at compile time?

2017-12-20 Thread Mengu via Digitalmars-d-learn
On Wednesday, 20 December 2017 at 16:54:35 UTC, Marc wrote: Give this function I'd like to run it at compile time: import std.concurrency : Generator, yield; [...] but when I do: [...] I get the following erros:

Re: weird exception on windows

2017-12-18 Thread Mengu via Digitalmars-d-learn
On Saturday, 16 December 2017 at 14:05:28 UTC, Vino wrote: On Saturday, 16 December 2017 at 13:59:11 UTC, Vino wrote: On Saturday, 16 December 2017 at 12:39:53 UTC, Kagamin wrote: [...] H, All, Are are also getting the same exception on Windows after updating the dmd to version v2.077.1,

Re: GUI program on Mac OS in D?

2017-12-14 Thread Mengu via Digitalmars-d-learn
On Thursday, 14 December 2017 at 14:07:25 UTC, Adam D. Ruppe wrote: I was playing with this myself based on Jacob's code and made it look like this: extern (Objective-C) interface ViewController : NSViewController { extern (C) @ObjCMethodOverride("loadView") static

Re: Sort characters in string

2017-12-07 Thread Mengu via Digitalmars-d-learn
On Wednesday, 6 December 2017 at 12:43:09 UTC, Fredrik Boulund wrote: On Wednesday, 6 December 2017 at 10:42:31 UTC, Dgame wrote: Or you simply do writeln("longword".array.sort); This is so strange. I was dead sure I tried that but it failed for some reason. But after trying it

Re: lower case only first letter of word

2017-12-05 Thread Mengu via Digitalmars-d-learn
On Tuesday, 5 December 2017 at 14:34:57 UTC, Mengu wrote: On Tuesday, 5 December 2017 at 14:01:35 UTC, Marc wrote: On Tuesday, 5 December 2017 at 13:40:08 UTC, Daniel Kozak wrote: [...] Yes, this is not what I want. I want to convert only the first letter of the word to lower case and left

Re: lower case only first letter of word

2017-12-05 Thread Mengu via Digitalmars-d-learn
On Tuesday, 5 December 2017 at 14:01:35 UTC, Marc wrote: On Tuesday, 5 December 2017 at 13:40:08 UTC, Daniel Kozak wrote: but this will change all other uppercase to lowercase, so maybe it is not what you want. If you really want just change first char to upper, then there is nothing wrong to

Re: git workflow for D

2017-12-03 Thread Mengu via Digitalmars-d-learn
On Sunday, 3 December 2017 at 20:05:47 UTC, bitwise wrote: I've finally started learning git, due to our team expanding beyond one person - awesome, right? Anyways, I've got things more or less figured out, which is nice, because being clueless about git is a big blocker for me trying to do

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

2017-09-29 Thread Mengu via Digitalmars-d-learn
On Friday, 29 September 2017 at 02:34:08 UTC, DreadKyller wrote: On Thursday, 28 September 2017 at 14:01:33 UTC, user1234 wrote: [...] I understand that, but because the operator isn't defined normally for classes unless overloaded, then your statement about this being an inconsistency on

Re: What does ! mean?

2017-09-27 Thread Mengu via Digitalmars-d-learn
On Wednesday, 27 September 2017 at 17:58:27 UTC, Ali Çehreli wrote: On 09/27/2017 08:33 AM, Ky-Anh Huynh wrote: > [...] Wissner wrote: > [...] The fact that such an important operator is explained so late in the book is due to the book's strong desire to have a linear flow. [...] ustad,

Re: segfault on gc.impl.conservative.gc.Gcx.smallAlloc

2017-09-26 Thread Mengu via Digitalmars-d-learn
On Tuesday, 26 September 2017 at 17:06:28 UTC, drug wrote: 26.09.2017 00:34, Mengu пишет: [...] not big deal probably, but isn't ~32GB enormous value here? I would check why bigDataFun return this. i could not find out why. d certainly needs to improve on freebsd. i don't think devs

Re: segfault on gc.impl.conservative.gc.Gcx.smallAlloc

2017-09-26 Thread Mengu via Digitalmars-d-learn
On Monday, 25 September 2017 at 21:34:40 UTC, Mengu wrote: hi all this following code block [0] is exiting with "terminated by signal SIGBUS (Misaligned address error)" error. it processes like 200K rows and then fails. any ideas? [...] hi all does anyone else have any ideas?

Re: segfault on gc.impl.conservative.gc.Gcx.smallAlloc

2017-09-26 Thread Mengu via Digitalmars-d-learn
On Tuesday, 26 September 2017 at 00:36:36 UTC, Vladimir Panteleev wrote: On Monday, 25 September 2017 at 21:34:40 UTC, Mengu wrote: delete fileContents; This looks suspicious - it is a slice of the memory-mapped file, not memory on the GC-managed heap, so "delete" is inapplicable to it.

segfault on gc.impl.conservative.gc.Gcx.smallAlloc

2017-09-25 Thread Mengu via Digitalmars-d-learn
hi all this following code block [0] is exiting with "terminated by signal SIGBUS (Misaligned address error)" error. it processes like 200K rows and then fails. any ideas? void getHotels() { import std.parallelism : taskPool; import std.functional : partial; auto sunHotels =

how to build project with locally compiled phobos

2017-09-23 Thread Mengu via Digitalmars-d-learn
hi all i've successfully compiled phobos master with gmake on freebsd. (make fails, i've no clue at all as to why) how do i compile my project now against my local phobos with dub? with plain dmd? i tried (in dub.sdl): - full path to new libphobos.so with -defaultlib to dflags - full path

Re: [FreeBSD] 0x000000000061d8cd in rt.aaA.Impl.findSlotLookup(ulong, const(void*), const(TypeInfo)) inout ()

2017-09-23 Thread Mengu via Digitalmars-d-learn
On Saturday, 23 September 2017 at 11:23:26 UTC, Nicholas Wilson wrote: On Saturday, 23 September 2017 at 08:45:00 UTC, Mengu wrote: [...] So it fails: trying to find if an element exists in an AA in a regex invoked as a callback from curl inside a parallel foreach. Interesting that it just

[FreeBSD] 0x000000000061d8cd in rt.aaA.Impl.findSlotLookup(ulong, const(void*), const(TypeInfo)) inout ()

2017-09-23 Thread Mengu via Digitalmars-d-learn
hello everyone i have a small program that parses an xml file, holding a list with 13610 elements. after making the list, it iterates over the list (paralele), goes to a web site and grabs the related data for that element. it works perfect for the first 1K element in the list. after that

Re: How to specify a template that uses unqualified type, like any normal function

2017-08-14 Thread Mengu via Digitalmars-d-learn
On Monday, 14 August 2017 at 13:48:36 UTC, Dominikus Dittes Scherkl wrote: if I use fixed-type functions, I can do the following: uint foo(uint n) { ++n; // modify n - as this function has received a copy of n, this is always possible return 42; } uint bar(const uint n) {

Re: gtkD load images

2017-08-03 Thread Mengu via Digitalmars-d-learn
On Thursday, 3 August 2017 at 03:59:40 UTC, Johnson Jones wrote: How can be use gtkD to load images, I assume through gdkpixbuf? While I am getting errors loading images through glade's image: (test.exe:8188): Gtk-WARNING **: Could not load image 'a.jpg': Couldn't recognize the

Re: in a template argument, specify which object member to access?

2016-02-08 Thread Mengu via Digitalmars-d-learn
On Monday, 8 February 2016 at 21:09:47 UTC, cy wrote: object.member lets me access the member of the object, but what if I want to access those members in a generic way, but in a different arrangement depending on context? Like if I wanted to first follow a tree down, and second priority would

Re: in a template argument, specify which object member to access?

2016-02-08 Thread Mengu via Digitalmars-d-learn
On Monday, 8 February 2016 at 22:46:06 UTC, cy wrote: On Monday, 8 February 2016 at 22:38:45 UTC, Mengu wrote: i believe you can use __traits(getMember) there. Great! Should have refreshed before sending that reply... I wonder if mixin("a."~member) is better or worse than

Re: OT: why do people use python when it is slow?

2015-10-18 Thread Mengu via Digitalmars-d-learn
On Sunday, 18 October 2015 at 13:29:50 UTC, Ola Fosheim Grøstad wrote: On Sunday, 18 October 2015 at 12:50:43 UTC, Namespace wrote: On Tuesday, 13 October 2015 at 23:26:14 UTC, Laeeth Isharc wrote: https://www.quora.com/Why-is-Python-so-popular-despite-being-so-slow Andrei suggested posting

Re: OT: why do people use python when it is slow?

2015-10-14 Thread Mengu via Digitalmars-d-learn
On Wednesday, 14 October 2015 at 05:42:12 UTC, Ola Fosheim Grøstad wrote: On Tuesday, 13 October 2015 at 23:26:14 UTC, Laeeth Isharc wrote: https://www.quora.com/Why-is-Python-so-popular-despite-being-so-slow Andrei suggested posting more widely. That's flaimbait: «Many really popular

Re: OT: interesting talk by Jane Street technical guy on why they used Ocaml

2015-10-03 Thread Mengu via Digitalmars-d-learn
On Saturday, 3 October 2015 at 01:41:55 UTC, Laeeth Isharc wrote: https://www.youtube.com/watch?v=hKcOkWzj0_s a little old but still relevant. talks about importance of brevity and strong types for readability (also avoiding boilerplate). two of the partners there committed to read every

Re: OT: interesting talk by Jane Street technical guy on why they used Ocaml

2015-10-03 Thread Mengu via Digitalmars-d-learn
On Saturday, 3 October 2015 at 16:33:38 UTC, Laeeth Isharc wrote: On Saturday, 3 October 2015 at 15:58:38 UTC, Mengu wrote: On Saturday, 3 October 2015 at 01:41:55 UTC, Laeeth Isharc wrote: https://www.youtube.com/watch?v=hKcOkWzj0_s a little old but still relevant. talks about importance of

Re: endsWith - for a string vs an array of strings

2015-01-11 Thread Mengu via Digitalmars-d-learn
On Saturday, 10 January 2015 at 23:32:47 UTC, bearophile wrote: Laeeth Isharc: In D there is a feature that allows a function to accept both an array of items and items, yes - it is funny there is not an overloading that accepts arrays I meant this D feature: void foo(T)(T[] items...) {

Re: idiomatic D: what to use instead of pointers in constructing a tree data structure?

2015-01-08 Thread Mengu via Digitalmars-d-learn
On Thursday, 8 January 2015 at 11:29:30 UTC, Laeeth Isharc wrote: this conversation is so funny: well what's wrong with this . It's a keyword... Aa Ha ha ha ha , rol. Seriously, is it so complicated to use a D editor ? I mean with syntax color... Man afraid to ask stoopid questions stays

Re: Learning D for a non computer science background person : pre-requisite knowledge?

2014-12-05 Thread Mengu via Digitalmars-d-learn
On Wednesday, 3 December 2014 at 02:41:16 UTC, Shriramana Sharma via Digitalmars-d-learn wrote: On Tue, Dec 2, 2014 at 10:45 PM, Mayuresh Kathe via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Okay, if that is the case, I'll dive into Mr. Alexandrescu's book as soon as I get my

Re: Disabling SSL Verification on std.net.curl

2014-05-16 Thread Mengu via Digitalmars-d-learn
On Friday, 16 May 2014 at 04:58:47 UTC, Jack wrote: A follow up from : http://forum.dlang.org/thread/nsdomtdbqqlylrmgo...@forum.dlang.org I discovered that it was not a C::B issue as I already compiled it with Xamarin Studio and it was still spewing out the error:

Re: D Newbie Trying to Use D with Major C Libraries

2014-05-16 Thread Mengu via Digitalmars-d-learn
On Friday, 16 May 2014 at 09:44:11 UTC, bearophile wrote: John Colvin: Any plans to get any preprocessor stuff working? Do you mean in D? Bye, bearophile i think he means in dstep.

Re: TKD AddProtocolCommand example

2014-05-15 Thread Mengu via Digitalmars-d-learn
On Thursday, 15 May 2014 at 17:30:22 UTC, Gary Willoughby wrote: On Wednesday, 14 May 2014 at 21:23:02 UTC, DaveG wrote: tkd\window\window.d(426): Error: undefined identifier CommandCallback Added the missing import and now all works fine. Fixed in v1.0.5-beta. Any more issues open them up

Re: TKD set focus on window?

2014-05-14 Thread Mengu via Digitalmars-d-learn
On Wednesday, 14 May 2014 at 17:08:21 UTC, Joakim wrote: Hi, Quick question regarding TKD (tkinter): Is there a way to set focus on the application window automatically on run? I'm on Mac OS X if that's of any importance. I have tried to grep the documentation but I can't find anything

Re: How to use the std.process?

2014-05-13 Thread Mengu via Digitalmars-d-learn
On Tuesday, 13 May 2014 at 08:56:43 UTC, FrankLike wrote: I want to start the process by std.process. module main; import std.process,std.stdio; void main() { string url = http://dlang.org/;; executeShell(escapeShellCommand(wget, url, -O, dlang-index.html));

Re: How to use the std.process?

2014-05-13 Thread Mengu via Digitalmars-d-learn
On Tuesday, 13 May 2014 at 10:48:06 UTC, FrankLike wrote: does it work when you run iexplore localhost:8000 in command line? is path to iexplore in your windows path? Ok,I get the answer by myself. module main; import std.process,std.stdio; void main() { //spawnProcess(C:\\Program Files

Re: Need help with movement from C to D

2014-05-08 Thread Mengu via Digitalmars-d-learn
On Tuesday, 6 May 2014 at 15:13:41 UTC, Artur Skawina via Digitalmars-d-learn wrote: On 05/06/14 16:45, via Digitalmars-d-learn wrote: On Tuesday, 6 May 2014 at 14:25:01 UTC, Artur Skawina via Digitalmars-d-learn wrote: I'm not sure why you'd want to wrap the .offsetof expression in a

Re: strange error with std.net.curl

2014-05-07 Thread Mengu via Digitalmars-d-learn
On Sunday, 4 May 2014 at 16:40:08 UTC, Suliman wrote: I am trying to compile next code: import std.net.curl; import std.stdio; void main() { writeln(get(https://google.com/;)); } and got next error http://www.everfall.com/paste/id.php?y37dr6qmu54h this is related to verifying