Re: Pro programmer

2019-08-26 Thread Chris via Digitalmars-d-learn
On Monday, 26 August 2019 at 06:46:04 UTC, GreatSam4sure wrote: What is the path of becoming very good at programming? Which language will one start with. Often it's the language that best solves the problem at hand for you, but it really depends on what you want to achieve. For fast scrip

Deserializing JSON as an abstract type

2019-11-18 Thread Chris via Digitalmars-d-learn
So I'm trying to make a D wrapper for Telegram's JSON API using libtdjson. All results coming from the JSON API take the following structure: { "@type": "className", "foo": "bar", "baz" { "@type": "otherClass" } } where every object, including nested ones, has a "@type" field whic

Pass range to a function

2017-07-27 Thread Chris via Digitalmars-d-learn
I'm using regex `matchAll`, and mapping it to get a sequence of strings. I then want to pass that sequence to a function. What is the general "sequence of strings" type declaration I'd need to use? In C#, it'd be `IEnumerable`. I'd rather not do a to-array on the sequence, if possible. (e.g.

Undefined Reference to OpenSSL EVP functions

2018-01-15 Thread Chris via Digitalmars-d-learn
I am trying to hook up OpenSSL to a dlang project I'm working on, but I have hit a problem when trying to link. I currently get the following linking error: undefined reference to `EVP_CIPHER_CTX_init' I have made sure to include the module wrapping the c headers import deimos.openssl.evp;

Re: Undefined Reference to OpenSSL EVP functions

2018-01-15 Thread Chris via Digitalmars-d-learn
On Tuesday, 16 January 2018 at 00:52:09 UTC, Chris wrote: I am trying to hook up OpenSSL to a dlang project I'm working on, but I have hit a problem when trying to link. I currently get the following linking error: undefined reference to `EVP_CIPHER_CTX_init' I have made sure to include the

[vibe.d/dub] Linker error

2018-03-09 Thread Chris via Digitalmars-d-learn
I got this error msg today (see below): DUB version 1.8.0, built on Mar 3 2018 vibe.d version 0.8.3 dmd 2.078.3 (the same with 2.079.0 and 2.077.0) .dub/build/server64_72_debug-debug-linux.posix-x86_64-dmd_2079-CAC4A12AC8FE4B4625A9511E4EFEB8F6/anscealai.o: In function `_D3std5range10primitive

Re: [vibe.d/dub] Linker error

2018-03-12 Thread Chris via Digitalmars-d-learn
On Friday, 9 March 2018 at 13:46:33 UTC, Chris wrote: I got this error msg today (see below): DUB version 1.8.0, built on Mar 3 2018 vibe.d version 0.8.3 dmd 2.078.3 (the same with 2.079.0 and 2.077.0) .dub/build/server64_72_debug-debug-linux.posix-x86_64-dmd_2079-CAC4A12AC8FE4B4625A9511E4EFEB

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

2015-10-15 Thread Chris via Digitalmars-d-learn
On Wednesday, 14 October 2015 at 18:37:40 UTC, Mengu wrote: 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 m

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

2015-10-15 Thread Chris via Digitalmars-d-learn
On Wednesday, 14 October 2015 at 18:17:29 UTC, Russel Winder wrote: The thing about Python is NumPy, SciPy, Pandas, Matplotlib, IPython, Jupyter, GNU Radio. The data science, bioinformatics, quant, signal provessing, etc. people do not give a sh!t which language they used, what they want is

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

2015-10-15 Thread Chris via Digitalmars-d-learn
On Thursday, 15 October 2015 at 09:47:56 UTC, Ola Fosheim Grøstad wrote: On Thursday, 15 October 2015 at 09:24:52 UTC, Chris wrote: Yep. This occurred to me too. Sorry Ola, but I think you don't know how sausages are made. I most certainly do. I am both doing backend programming and we have a

Re: LuaD: creating a flexible data filter system

2015-10-16 Thread Chris via Digitalmars-d-learn
On Friday, 16 October 2015 at 09:01:57 UTC, yawniek wrote: hi, i'm reading in a stream of data that is deserialized into individual frames. a frame is either of: a) a specific D datastructure ( struct with a few ulong,string,string[string] etc members), known at compile time b) json (prefer

Re: LuaD: creating a flexible data filter system

2015-10-17 Thread Chris via Digitalmars-d-learn
On Saturday, 17 October 2015 at 02:02:16 UTC, Jakob Ovrum wrote: On Friday, 16 October 2015 at 10:45:52 UTC, Chris wrote: Later you call the function with the Lua C API like "lua_pcall(L, 0, 1, 0);". It's a bit tricky to move things around on the Lua stack, but you'll get there! ;) Or you cou

Re: good reasons not to use D?

2015-11-03 Thread Chris via Digitalmars-d-learn
On Friday, 30 October 2015 at 10:35:03 UTC, Laeeth Isharc wrote: Interesting. Two points suggest that you should use D only for serious programming: "cases where you want to write quick one-off scripts that need to use a bunch of different libraries not yet available in D and where it doesn'

Re: bearophile is back! :) was: Re: conver BigInt to string

2015-11-05 Thread Chris via Digitalmars-d-learn
On Thursday, 5 November 2015 at 19:30:02 UTC, Ali Çehreli wrote: On 11/05/2015 09:40 AM, bearophile wrote: Bye, bearophile Were you immersed in another language? Rust? Ali His D doesn't seem to be Rusty though!

Re: bearophile is back! :) was: Re: conver BigInt to string

2015-11-05 Thread Chris via Digitalmars-d-learn
On Thursday, 5 November 2015 at 19:38:23 UTC, Ali Çehreli wrote: Good one! ;) I'm really happy that he is still around. Ali So am I! The more, the merrier!

Invalid foreach aggregate

2015-11-16 Thread Chris via Digitalmars-d-learn
Updating my code from 2.067.1 to 2.069.1 (I skipped 2.068, because I was too busy). I get this error: invalid foreach aggregate, define opApply(), range primitives, or use .tupleof for code like foreach (ref it; myArray.doSomething) {} Probably not the best idea anyway. What's the best fix

Re: Invalid foreach aggregate

2015-11-16 Thread Chris via Digitalmars-d-learn
On Monday, 16 November 2015 at 16:49:19 UTC, Marc Schütz wrote: On Monday, 16 November 2015 at 16:44:27 UTC, Chris wrote: Updating my code from 2.067.1 to 2.069.1 (I skipped 2.068, because I was too busy). I get this error: invalid foreach aggregate, define opApply(), range primitives, or us

Re: Invalid foreach aggregate

2015-11-16 Thread Chris via Digitalmars-d-learn
On Monday, 16 November 2015 at 17:57:53 UTC, opla wrote: On Monday, 16 November 2015 at 16:55:29 UTC, Chris wrote: On Monday, 16 November 2015 at 16:49:19 UTC, Marc Schütz wrote: On Monday, 16 November 2015 at 16:44:27 UTC, Chris wrote: Updating my code from 2.067.1 to 2.069.1 (I skipped 2.068,

Re: Invalid foreach aggregate

2015-11-17 Thread Chris via Digitalmars-d-learn
I've checked several options now and it doesn't work. Here (http://dlang.org/statement.html#foreach-with-ranges) it is stated that it suffices to have range primitives, if opApply doesn't exist. My code worked up to 2.068.0, with the introduction of 2.068.1 it failed. I wonder why that is. I

Re: Invalid foreach aggregate

2015-11-17 Thread Chris via Digitalmars-d-learn
On Tuesday, 17 November 2015 at 11:26:19 UTC, Marc Schütz wrote: That really depends on the details, that's why I asked. It could be a regression, or it could be that the compiler now does stricter checking than before, and your implementation wasn't completely correct, or it could be a bug

Re: Invalid foreach aggregate

2015-11-17 Thread Chris via Digitalmars-d-learn
On Tuesday, 17 November 2015 at 11:58:22 UTC, Chris wrote: Sorry that should be: @property void popFront() { r = r[1..$]; cnt++; }

Re: Invalid foreach aggregate

2015-11-17 Thread Chris via Digitalmars-d-learn
On Tuesday, 17 November 2015 at 12:22:22 UTC, Marc Schütz wrote: Ok, that's a strange implementation of opIndex(). Usually, a parameter-less opIndex() is supposed to return a slice into the full range, but yours returns a size_t, which of course can't be iterated over. The change that made

Re: Invalid foreach aggregate

2015-11-17 Thread Chris via Digitalmars-d-learn
On Tuesday, 17 November 2015 at 13:49:58 UTC, Marc Schütz wrote: On Tuesday, 17 November 2015 at 12:41:45 UTC, Chris wrote: On Tuesday, 17 November 2015 at 12:22:22 UTC, Marc Schütz wrote: In any case, I'd suggest you fix your opIndex(), except if there's a really good reason it is as it is.

What's wrong with my debugger?

2015-12-23 Thread Chris via Digitalmars-d-learn
Please see the linked screenshot: http://i.imgur.com/SpkXu5m.png As you can see, the inside, outside and collision arrays don't seem to work with the debugger. They show a bogus lenght and a bogus memory address. Extracting the lenghts to separate variables outl, insl and coll show that the ar

Re: What's wrong with my debugger?

2015-12-24 Thread Chris via Digitalmars-d-learn
On Thursday, 24 December 2015 at 09:30:24 UTC, Rainer Schuetze wrote: In the locals window, mago displays all instances of variables, but with the same value (which might be some uninitialized value of a different declaration than expected). The Visual Studio debug engine shows different values

Assoc Array for Concurrency

2016-02-29 Thread Chris via Digitalmars-d-learn
What's the best way to make an assoc array fit for multi-threading? If this is not possible what would be the best alternative? Say, for example, `data` is used by a class that is globally accessible to all threads. E.g. like this: string[string] data; // defined somewhere public string ge

Re: Assoc Array for Concurrency

2016-03-02 Thread Chris via Digitalmars-d-learn
On Monday, 29 February 2016 at 17:38:11 UTC, ZombineDev wrote: On Monday, 29 February 2016 at 12:43:39 UTC, Chris wrote: [...] I'm almost sure that built-in AAs don't provide automatic synchronization (in my tests I hit a deadlock), but you can easily wrap the AA into a struct that does the

C.h to D conversion (structs)

2016-03-15 Thread Chris via Digitalmars-d-learn
I've converted a C.h file to D according to this guide: http://wiki.dlang.org/Converting_C_.h_Files_to_D_Modules and examples in deimos: https://github.com/D-Programming-Deimos/ However, I get an error when trying to use a struct that uses structs. struct A { size_t i; } struct B { siz

Re: C.h to D conversion (structs)

2016-03-15 Thread Chris via Digitalmars-d-learn
On Tuesday, 15 March 2016 at 16:44:10 UTC, Adam D. Ruppe wrote: On Tuesday, 15 March 2016 at 16:32:56 UTC, Chris wrote: The error I get is something like undefined reference to `_D3test7testmodule13A6__initZ' undefined reference to `_D3test7testmodule13B6__initZ' You still need to compile/li

Re: C.h to D conversion (structs)

2016-03-15 Thread Chris via Digitalmars-d-learn
On Tuesday, 15 March 2016 at 17:10:03 UTC, Adam D. Ruppe wrote: On Tuesday, 15 March 2016 at 16:56:00 UTC, Chris wrote: Do you mean I need to void initialize them in the C code or in D? And if in D, how would I do that, with `static this`? in D, at the usage point with =void where you declare

Re: C.h to D conversion (structs)

2016-03-15 Thread Chris via Digitalmars-d-learn
On Tuesday, 15 March 2016 at 18:47:22 UTC, Adam D. Ruppe wrote: Like you would another D library. Now I get it! Yes, that works as expected. The problem isn't the struct itself, but the D initializer. Structs in C don't have initalizers but do in D: struct Foo { int a = 10; /* illegal

Dynamic library

2016-04-11 Thread Chris via Digitalmars-d-learn
I followed these steps: https://dlang.org/dll-linux.html#dso7 What I get is this error: libphobos2.so: file format not recognized; treating as linker script I don't know why it is not recognized. Any ideas?

Re: Dynamic library

2016-04-11 Thread Chris via Digitalmars-d-learn
On Monday, 11 April 2016 at 11:42:22 UTC, Chris wrote: I followed these steps: https://dlang.org/dll-linux.html#dso7 What I get is this error: libphobos2.so: file format not recognized; treating as linker script I don't know why it is not recognized. Any ideas? For the record, I fixed it

Re: Dynamic library

2016-04-11 Thread Chris via Digitalmars-d-learn
On Monday, 11 April 2016 at 13:45:42 UTC, Adam D. Ruppe wrote: On Monday, 11 April 2016 at 13:40:14 UTC, Chris wrote: For the record, I fixed it by changing the contents of libphobos2.so from How did you do that btw? The file there should really just be a link to some binary file, maybe it go

Re: Dynamic library

2016-04-11 Thread Chris via Digitalmars-d-learn
I wanted to test, if I could use D with JNA (Java Native Access). I get this error message: # A fatal error has been detected by the Java Runtime Environment: # # SIGSEGV (0xb) at pc=0x7fd24ab66074, pid=15733, tid=140541714827008 # # JRE version: OpenJDK Runtime Environment (8.0_66-b17) (

djvm fails to build

2016-04-12 Thread Chris via Digitalmars-d-learn
@Rikki I can't get djvm to build (dmd 2.069.1 and higher) https://github.com/rikkimax/djvm [Error Message] Performing "debug" build using dmd for x86_64. djvm ~master: building configuration "library"... String (Constructor!string, Constructor!(), Method!(char, "charAt", int), Method!(string,

DWT Cloning / Build fails

2016-04-12 Thread Chris via Digitalmars-d-learn
This doesn't work: $ git clone --recursive git://github.com/d-widget-toolkit/dwt.git $ git clone --recursive https://github.com/d-widget-toolkit/dwt.git (cf. https://github.com/d-widget-toolkit/dwt) If I just download the master or clone without `--recursive`, files are missing and I cannot

Re: djvm fails to build

2016-04-12 Thread Chris via Digitalmars-d-learn
On Tuesday, 12 April 2016 at 15:54:10 UTC, rikki cattermole wrote: I'll look into it tomorrow, but I suspect I'm gonna need to do some serious work to get it work with the new import rules. Also maybe best to take this to gitter[0] or github issue so that I get an alert. [0] https://gitter.i

Re: Dynamic library

2016-04-12 Thread Chris via Digitalmars-d-learn
On Tuesday, 12 April 2016 at 10:11:27 UTC, Russel Winder wrote: On Mon, 2016-04-11 at 14:15 +, Chris via Digitalmars-d-learn wrote: I wanted to test, if I could use D with JNA (Java Native Access). I get this error message: # A fatal error has been detected by the Java Runtime

Re: DWT Cloning / Build fails

2016-04-13 Thread Chris via Digitalmars-d-learn
On Tuesday, 12 April 2016 at 19:20:44 UTC, Jacob Carlborg wrote: The error messages are below. If I do it step by step (without --recursive) and then "git submodule update --init", I get more or less the same error: Cloning into 'base'... fatal: unable to connect to github.com: github.com[0:

Re: Dynamic library

2016-04-13 Thread Chris via Digitalmars-d-learn
On Tuesday, 12 April 2016 at 10:11:27 UTC, Russel Winder wrote: Did you solve this problem? Does it go away using a newer JDK, e.g. 8_77? Have you tried the Oracle or Azul builds? If you have a small project you can send me that exhibits the problem for you, I can take a look at it. I coul

Re: DWT Cloning / Build fails

2016-04-14 Thread Chris via Digitalmars-d-learn
On Wednesday, 13 April 2016 at 18:50:22 UTC, Jacob Carlborg wrote: On 2016-04-13 17:23, Jesse Phillips wrote: Looks like your firewall is blocking the git protocol. Checkout dwt without --recursive Modify the .gitmodules file so that https:// urls are used instead of git Run the git submod

Re: DWT Cloning / Build fails

2016-04-14 Thread Chris via Digitalmars-d-learn
For the record, on my Linux (Ubuntu 15), I had to tweak the command for the example: dmd main.d -I/imp -J/org.eclipse.swt.gtk.linux.x86/res -L-L/lib \ -L-l:org.eclipse.swt.gtk.linux.x86.a \ -L-l:dwt-base.a -L-lgtk-x11-2.0 -L-lgdk-x11-2.0 -L-latk-1.0 -L-lgdk_pixbuf-2.0 \ -L-lgthread-2.0

Re: DWT Cloning / Build fails

2016-04-15 Thread Chris via Digitalmars-d-learn
On Thursday, 14 April 2016 at 19:16:30 UTC, Jacob Carlborg wrote: On 2016-04-14 15:56, Chris wrote: I had to add ".a" to `-L-l:dwt-base` and `-L-l:org.eclipse.swt.gtk.linux.x86`, and add `-L-lgnomevfs-2` as well. I added `-L-lgnomevfs-2 to the example. I need to look into way the ".a" was n

Re: Linker error for d.o: relocation R_X86_64_32 against `__dmd_personality_v0'

2016-04-20 Thread Chris via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 12:04:45 UTC, rcorre wrote: === $ dmd /tmp/d.d /usr/bin/ld: d.o: relocation R_X86_64_32 against `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC d.o: error adding symbols: Bad value collect2: error: ld returned 1 exit statu

Re: Linker error for d.o: relocation R_X86_64_32 against `__dmd_personality_v0'

2016-04-21 Thread Chris via Digitalmars-d-learn
On Thursday, 21 April 2016 at 01:20:27 UTC, rcorre wrote: s/compile/link I _can_ compile a D library, but as soon as I try to link anything compiled with DMD it falls over. Sorry, I didn't see the code in your first post. I tried it myself (in only have 2.070.2) and it worked fine. Have y

Re: Linker error for d.o: relocation R_X86_64_32 against `__dmd_personality_v0'

2016-04-22 Thread Chris via Digitalmars-d-learn
On Friday, 22 April 2016 at 09:49:02 UTC, Rene Zwanenburg wrote: On Thursday, 21 April 2016 at 16:29:14 UTC, rcorre wrote: - What happens when you compile a binary without phobos and druntime, and with a custom entry point? I've never done that myself and don't remember how to do that off the t

DlangIDE Themes

2016-05-11 Thread Chris via Digitalmars-d-learn
Is there a way I can add my own themes? I've created a theme file and added it to views/resources.list However, it doesn't show up. "Default" and "Dark" seem to be hardwired somewhere in the source code.

static import (v2.071.0)

2016-05-11 Thread Chris via Digitalmars-d-learn
I'm updating my code to 2.071.0 at the moment. Naturally, I get a lot of warnings like `module std.uni is not accessible here, perhaps add 'static import std.uni;'` Will `static import` bloat my exe or simply access the members I use?

Re: static import (v2.071.0)

2016-05-11 Thread Chris via Digitalmars-d-learn
On Wednesday, 11 May 2016 at 14:18:16 UTC, Vladimir Panteleev wrote: On Wednesday, 11 May 2016 at 14:11:46 UTC, Chris wrote: I'm updating my code to 2.071.0 at the moment. Naturally, I get a lot of warnings like `module std.uni is not accessible here, perhaps add 'static import std.uni;'`

Re: static import (v2.071.0)

2016-05-11 Thread Chris via Digitalmars-d-learn
On Wednesday, 11 May 2016 at 14:28:00 UTC, Vladimir Panteleev wrote: On Wednesday, 11 May 2016 at 14:26:37 UTC, Vladimir Panteleev wrote: On Wednesday, 11 May 2016 at 14:24:03 UTC, Chris wrote: I was wondering if `static import std.file;` `if (exists(file))` will only import `std.file.exists

Re: static import (v2.071.0)

2016-05-11 Thread Chris via Digitalmars-d-learn
On Wednesday, 11 May 2016 at 14:34:15 UTC, Edwin van Leeuwen wrote: On Wednesday, 11 May 2016 at 14:24:03 UTC, Chris wrote: I was wondering if `static import std.file;` `if (exists(file))` will only import `std.file.exists` or the whole lot of `std.file`? I want to find out what the best str

Re: static import (v2.071.0)

2016-05-11 Thread Chris via Digitalmars-d-learn
On Wednesday, 11 May 2016 at 14:28:00 UTC, Vladimir Panteleev wrote: On Wednesday, 11 May 2016 at 14:26:37 UTC, Vladimir Panteleev wrote: To elaborate - this doesn't imply that the code of everything in that module will always be placed in the executable. The exact details depend on the imple

Re: DlangIDE Themes

2016-05-12 Thread Chris via Digitalmars-d-learn
On Thursday, 12 May 2016 at 03:01:02 UTC, thedeemon wrote: On Wednesday, 11 May 2016 at 12:55:13 UTC, Chris wrote: Is there a way I can add my own themes? I've created a theme file and added it to views/resources.list However, it doesn't show up. "Default" and "Dark" seem to be hardwired some

Re: DlangIDE Themes

2016-05-12 Thread Chris via Digitalmars-d-learn
On Thursday, 12 May 2016 at 09:51:18 UTC, thedeemon wrote: On Thursday, 12 May 2016 at 09:17:24 UTC, Chris wrote: They shouldn't be hardwired. Best would be to load them dynamically with their respective names encoded in the xml file. In this way people could add their own themes as they see

Re: static import (v2.071.0)

2016-05-12 Thread Chris via Digitalmars-d-learn
On Thursday, 12 May 2016 at 12:45:38 UTC, Steven Schveighoffer wrote: On 5/11/16 10:11 AM, Chris wrote: No. static import just defines what symbols are accessible in what contexts. The (likely) reason you are getting this is because you are importing a module with a selective import: impor

Re: DlangIDE Themes

2016-05-12 Thread Chris via Digitalmars-d-learn
On Thursday, 12 May 2016 at 15:29:17 UTC, Vadim Lopatin wrote: Hello, External themes support is planned. It is not a hard task. Btw, try to copy your resource files (res directory) to the same place dlangui executable (e.g. dlangide) is located. Resources from this directory must be accessi

Re: What's wrong with my usage of std.algorithm.map in this code example?

2016-05-25 Thread Chris via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 10:24:19 UTC, pineapple wrote: On Tuesday, 24 May 2016 at 20:18:34 UTC, Steven Schveighoffer wrote: Slice assignment from range to array is not supported. In your example, I'm curious why the efforts to specify the type? I think it would work with just saying auto

Re: What's wrong with my usage of std.algorithm.map in this code example?

2016-05-25 Thread Chris via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 11:14:26 UTC, FreeSlave wrote: Works with 'only', 'array' and static array slicing. import std.algorithm : map; import std.range : only; import std.conv : to; import std.stdio : writeln; import std.string : join; import std.array : array; string test(Args...)(in Ar

Re: What's wrong with my usage of std.algorithm.map in this code example?

2016-05-25 Thread Chris via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 12:08:20 UTC, Steven Schveighoffer wrote: On 5/25/16 6:24 AM, pineapple wrote: On Tuesday, 24 May 2016 at 20:18:34 UTC, Steven Schveighoffer wrote: Slice assignment from range to array is not supported. In your example, I'm curious why the efforts to specify the t

Re: What's wrong with my usage of std.algorithm.map in this code example?

2016-05-25 Thread Chris via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 13:27:28 UTC, Chris wrote: On Wednesday, 25 May 2016 at 12:08:20 UTC, Steven Schveighoffer wrote: On 5/25/16 6:24 AM, pineapple wrote: On Tuesday, 24 May 2016 at 20:18:34 UTC, Steven Schveighoffer wrote: Slice assignment from range to array is not supported. In yo

Re: What's wrong with my usage of std.algorithm.map in this code example?

2016-05-25 Thread Chris via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 14:32:11 UTC, ag0aep6g wrote: On 05/25/2016 03:27 PM, Chris wrote: Why can the tuple be iterated with foreach, as in my quick fix, and indexed with tuple[0..], but is not accepted as a range? What are the differences? popFront doesn't make sense with a tuple (aka

Re: What's wrong with my usage of std.algorithm.map in this code example?

2016-05-25 Thread Chris via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 14:48:14 UTC, ag0aep6g wrote: On 05/25/2016 04:39 PM, Chris wrote: I see. Maybe it would be worth adding a wrapper to typecons.Tuple or std.range that helps to rangify tuples. std.range.only is that wrapper. Duh! Of course! :-) I cannot think of any use case r

Re: What's wrong with my usage of std.algorithm.map in this code example?

2016-05-26 Thread Chris via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 19:07:32 UTC, Era Scarecrow wrote: On Wednesday, 25 May 2016 at 13:27:28 UTC, Chris wrote: Why can the tuple be iterated with foreach, as in my quick fix, and indexed with tuple[0..], but is not accepted as a range? What are the differences? Is there a way to rangif

Linker error

2016-06-10 Thread Chris via Digitalmars-d-learn
I get the error below with code like this: auto res = ['1', '2'].map!(a => a.to!string); dmd 2.071.0 What's wrong here? I import std.algorithm, std.range, std.array, std.conv in the module. (.data._D65TypeInfo_xC3std5range10interfaces18__T10InputRangeTiZ10InputRange6__initZ+0x10): undefined

Re: Linker error

2016-06-10 Thread Chris via Digitalmars-d-learn
On Friday, 10 June 2016 at 12:12:17 UTC, ketmar wrote: On Friday, 10 June 2016 at 12:04:50 UTC, Chris wrote: I get the error below with code like this: auto res = ['1', '2'].map!(a => a.to!string); dmd 2.071.0 What's wrong here? I import std.algorithm, std.range, std.array, std.conv in the m

Re: Linker error

2016-06-10 Thread Chris via Digitalmars-d-learn
On Friday, 10 June 2016 at 13:00:23 UTC, ketmar wrote: On Friday, 10 June 2016 at 12:52:05 UTC, Chris wrote: I use dub and `dvm use 2.071.0`. hm. sorry, i can't help you with this. straight "dmd test.d" is ok, so it's probably something with dub/dvm interaction... It doesn't compile with `

Re: Linker error

2016-06-10 Thread Chris via Digitalmars-d-learn
On Friday, 10 June 2016 at 13:17:32 UTC, Steven Schveighoffer wrote: On 6/10/16 8:04 AM, Chris wrote: I get the error below with code like this: auto res = ['1', '2'].map!(a => a.to!string); dmd 2.071.0 What's wrong here? I import std.algorithm, std.range, std.array, std.conv in the module.

Pointer to template types?

2014-04-28 Thread Chris via Digitalmars-d-learn
I need an array that contains pointers to types created via template. To stick to my usual example: Person!(string) How can I make an array with pointers to concrete "instances" of Person!(string)? Something like this only with pointers, i.e. buf holds pointers to concrete Person!(string)s:

Re: Pointer to template types?

2014-04-28 Thread Chris via Digitalmars-d-learn
On Monday, 28 April 2014 at 10:32:18 UTC, bearophile wrote: Chris: I need an array that contains pointers to types created via template. To stick to my usual example: Person!(string) How can I make an array with pointers to concrete "instances" of Person!(string)? Every template creates a

Re: Pointer to template types?

2014-04-28 Thread Chris via Digitalmars-d-learn
On Monday, 28 April 2014 at 10:32:18 UTC, bearophile wrote: Chris: I need an array that contains pointers to types created via template. To stick to my usual example: Person!(string) How can I make an array with pointers to concrete "instances" of Person!(string)? Every template creates a

Re: Pointer to template types?

2014-04-28 Thread Chris via Digitalmars-d-learn
On Monday, 28 April 2014 at 10:44:18 UTC, Rene Zwanenburg wrote: On Monday, 28 April 2014 at 10:40:49 UTC, Chris wrote: So there is no way of filling an array with something like Person!(string) *pptr; foreach(person; people) { buf ~= &person; } Person!(string)*[] arr; Like this? Exactl

Re: Pointer to template types?

2014-04-28 Thread Chris via Digitalmars-d-learn
On Monday, 28 April 2014 at 11:04:17 UTC, bearophile wrote: Chris: So there is no way of filling an array with something like Person!(string) *pptr; foreach(person; people) { buf ~= &person; } So you want an array filled with instances of the same instantiation, sorry, I misunderstood yo

Re: Pointer to template types?

2014-04-29 Thread Chris via Digitalmars-d-learn
On Tuesday, 29 April 2014 at 04:44:39 UTC, Jesse Phillips wrote: On Monday, 28 April 2014 at 10:40:49 UTC, Chris wrote: Person!(string) *pptr; Just wanted to point out, the above is C style and not recommended. Person!(string)* pptr, pptr2, pptr3; In D the pointer is part of the type n

Cost of assoc array?

2014-05-14 Thread Chris via Digitalmars-d-learn
I have code that uses the following: string[][size_t] myArray; 1. myArray = [0:["t", "o", "m"], 1:["s", "m", "i", "th"]]; However, I've found out that I never need an assoc array and a "linear" array would be just fine, as in 2. myArray = [["t", "o", "m"], ["s", "m", "i", "th"]]; Is there a

Re: Cost of assoc array?

2014-05-14 Thread Chris via Digitalmars-d-learn
On Wednesday, 14 May 2014 at 10:20:51 UTC, bearophile wrote: Chris: Is there any huge difference as regards performance and memory footprint between the two? Or is 2. basically 1. under the hood? An associative array is a rather more complex data structure, so if you don't need it, use some

Re: Cost of assoc array?

2014-05-14 Thread Chris via Digitalmars-d-learn
On Wednesday, 14 May 2014 at 11:13:10 UTC, John Colvin wrote: On Wednesday, 14 May 2014 at 09:38:10 UTC, Chris wrote: I have code that uses the following: string[][size_t] myArray; 1. myArray = [0:["t", "o", "m"], 1:["s", "m", "i", "th"]]; However, I've found out that I never need an assoc ar

Re: Cost of assoc array?

2014-05-14 Thread Chris via Digitalmars-d-learn
On Wednesday, 14 May 2014 at 13:31:53 UTC, dennis luehring wrote: Am 14.05.2014 15:20, schrieb Chris: Profiling is not really feasible, because for this to work properly, I would have to introduce the change first to be able to compare both. Nothing worse than carefully changing things only to f

Re: Cost of assoc array?

2014-05-14 Thread Chris via Digitalmars-d-learn
On Wednesday, 14 May 2014 at 13:44:40 UTC, John Colvin wrote: Yes, they are much faster. Normal array indexing is equivalent to *(myArray.ptr + index) plus an optional bounds check, whereas associative array indexing is a much, much larger job. Why were you using associative arrays in the fi

Bounds check

2014-05-23 Thread Chris via Digitalmars-d-learn
The following: import std.stdio; void main() { int[5] arg; arg[10] = 3; // Compiler says (of course): Error: array index 10 is out of bounds arg[0 .. 5] } import std.stdio; void main() { int[5] arg; foreach (i; 0..10) { arg[i] = i; } } Compiler says nothing, but w

Re: Bounds check

2014-05-23 Thread Chris via Digitalmars-d-learn
On Friday, 23 May 2014 at 15:25:37 UTC, Meta wrote: On Friday, 23 May 2014 at 15:14:47 UTC, Chris wrote: The following: import std.stdio; void main() { int[5] arg; arg[10] = 3; // Compiler says (of course): Error: array index 10 is out of bounds arg[0 .. 5] } import std.stdio

Re: What are the best std algo for testing a range implementation ?

2014-05-27 Thread Chris via Digitalmars-d-learn
On Tuesday, 27 May 2014 at 10:50:54 UTC, BicMedium wrote: Let's say I have a set of containers, using a D-unfriendly-semantic. They rather use a kind of ADA vocabulary (according to https://en.wikipedia.org/wiki/Deque). I want to make them "range-aware". If the input/output ranges are easy to

Cost of .dup vs. instantiation

2014-05-28 Thread Chris via Digitalmars-d-learn
I use Appender to fill an array. The Appender is a class variable and is not instantiated with each function call to save instantiation. However, the return value or the function must be dup'ed, like so: Appender!(MyType[]) append; public auto doSomething() { scope (exit) { // clear append }

Re: Cost of .dup vs. instantiation

2014-05-29 Thread Chris via Digitalmars-d-learn
On Wednesday, 28 May 2014 at 17:33:19 UTC, monarch_dodra wrote: On Wednesday, 28 May 2014 at 14:36:25 UTC, Chris wrote: I use Appender to fill an array. The Appender is a class variable and is not instantiated with each function call to save instantiation. However, the return value or the funct

Re: Cost of .dup vs. instantiation

2014-05-29 Thread Chris via Digitalmars-d-learn
On Thursday, 29 May 2014 at 12:04:35 UTC, monarch_dodra wrote: On Thursday, 29 May 2014 at 08:49:10 UTC, Chris wrote: monarch_dodra: Hm. This last point might be an issue. If I process a large input (text in this case) then I might run into trouble with "append" as a class variable. I also had

dub: strange behavior

2014-06-05 Thread Chris via Digitalmars-d-learn
I've just had the case where after changing the code and running "$ dub" nothing changed in the output. I couldn't make sense of it. Then I ran "$ dub --force" and the output was as expected. Has this happened to anyone. I think I came across this before.

splitter for strings

2014-06-09 Thread Chris via Digitalmars-d-learn
Say I wanna split a string that contains hyphens. If I use std.algorithm.splitter I end up with empty elements for each hyphen, e.g.: auto word = "bla-bla"; auto parts = appender!(string[]); w.splitter('-').copy(parts); // parts.data.length == 3 ["bla", "", "bla"] This is not ideal for my purp

Re: splitter for strings

2014-06-09 Thread Chris via Digitalmars-d-learn
On Monday, 9 June 2014 at 10:14:40 UTC, bearophile wrote: Chris: auto word = "bla-bla"; auto parts = appender!(string[]); w.splitter('-').copy(parts); // parts.data.length == 3 ["bla", "", "bla"] With the current dmd 2.066alpha this code: void main() { import std.stdio, std.string, std.a

Re: splitter for strings

2014-06-09 Thread Chris via Digitalmars-d-learn
On Monday, 9 June 2014 at 10:54:09 UTC, monarch_dodra wrote: On Monday, 9 June 2014 at 10:23:16 UTC, Chris wrote: Ok, thanks. I'll keep that in mind for the next version. Seems to me to also work with 2.065 and 2.064. From the library reference: assert(equal(splitter("hello world", ' '),

Re: splitter for strings

2014-06-09 Thread Chris via Digitalmars-d-learn
On Monday, 9 June 2014 at 11:16:18 UTC, monarch_dodra wrote: On Monday, 9 June 2014 at 11:04:12 UTC, Chris wrote: From the library reference: assert(equal(splitter("hello world", ' '), [ "hello", "", "world" ])); and "If a range with one separator is given, the result is a range with two

Re: splitter for strings

2014-06-09 Thread Chris via Digitalmars-d-learn
On Monday, 9 June 2014 at 12:16:30 UTC, monarch_dodra wrote: On Monday, 9 June 2014 at 11:40:24 UTC, Chris wrote: On Monday, 9 June 2014 at 11:16:18 UTC, monarch_dodra wrote: On Monday, 9 June 2014 at 11:04:12 UTC, Chris wrote: From the library reference: assert(equal(splitter("hello world",

Re: splitter for strings

2014-06-09 Thread Chris via Digitalmars-d-learn
On Monday, 9 June 2014 at 14:21:21 UTC, Steven Schveighoffer wrote: On Mon, 09 Jun 2014 07:04:11 -0400, Chris wrote: On Monday, 9 June 2014 at 10:54:09 UTC, monarch_dodra wrote: On Monday, 9 June 2014 at 10:23:16 UTC, Chris wrote: Ok, thanks. I'll keep that in mind for the next version.

Re: splitter for strings

2014-06-09 Thread Chris via Digitalmars-d-learn
On Monday, 9 June 2014 at 14:47:45 UTC, Steven Schveighoffer wrote: On Mon, 09 Jun 2014 10:39:39 -0400, Chris wrote: Atm, I have auto parts = appender!(string[]); w.splitter('-').filter!(a => !a.empty).copy(parts); Which looks more elegant and gives me what I want. IMO, the module that han

Re: splitter for strings

2014-06-09 Thread Chris via Digitalmars-d-learn
On Monday, 9 June 2014 at 15:52:24 UTC, monarch_dodra wrote: On Monday, 9 June 2014 at 15:19:05 UTC, Chris wrote: On Monday, 9 June 2014 at 14:47:45 UTC, Steven Schveighoffer wrote: On Mon, 09 Jun 2014 10:39:39 -0400, Chris wrote: Atm, I have auto parts = appender!(string[]); w.splitter('-

Re: splitter for strings

2014-06-09 Thread Chris via Digitalmars-d-learn
On Monday, 9 June 2014 at 18:09:07 UTC, monarch_dodra wrote: On Monday, 9 June 2014 at 17:57:24 UTC, Steven Schveighoffer wrote: I think we are confusing things here, I was talking about strip :) strip and split are actually both pretty much in the same boat actually in regards to that, so ju

Re: splitter for strings

2014-06-09 Thread Chris via Digitalmars-d-learn
On Monday, 9 June 2014 at 20:01:05 UTC, monarch_dodra wrote: On Monday, 9 June 2014 at 19:47:29 UTC, Chris wrote: Uh, I see, I misread the signature of std.string.strip(). So that's one option now, to strip all trailing hyphens with std.string.strip(). Well, I'll give it a shot tomorrow. No,

extern (C) Names & Signatures

2014-06-16 Thread Chris via Digitalmars-d-learn
I use a library written in C. There are these two functions 1. MyLib_Initialize(), an existing 3rd party function 2. my_lib_initialize(), my custom function On Linux (my main platform) it compiled and worked without an error. On Windows, however, implib printed a warning and said that two defi

DLLs with Cygwin don't work

2014-06-17 Thread Chris via Digitalmars-d-learn
The following: 1. created test C-dll in Cygwin (gcc -shared -o hello.dll hello.o) 2. used "implib.exe /s" to create .lib file 3. linked with D program "dmd test.d hello.lib" Compiles, program starts but begins to hang as soon as it calls the C function (which itself is never executed, no "hello

Re: DLLs with Cygwin don't work

2014-06-18 Thread Chris via Digitalmars-d-learn
On Tuesday, 17 June 2014 at 09:51:06 UTC, Chris wrote: The following: 1. created test C-dll in Cygwin (gcc -shared -o hello.dll hello.o) 2. used "implib.exe /s" to create .lib file 3. linked with D program "dmd test.d hello.lib" Compiles, program starts but begins to hang as soon as it calls

Concurrency on Windows (spawn)

2014-06-18 Thread Chris via Digitalmars-d-learn
Windows: in a D-DLL I'm trying to spawn a thread. However, nothing happens auto myThread = spawn(&myFunction, thisTid); send(myThread, arg); The thread is never called. Any ideas? Thanks! PS In an old DLL it used to work, there I called it with only one argument, i.e. spawn(&myFunction). Is t

  1   2   3   >