Re: Handling arbitrary char ranges

2016-04-20 Thread ag0aep6g via Digitalmars-d-learn
On 21.04.2016 04:35, Alex Parrill wrote: On Wednesday, 20 April 2016 at 22:44:37 UTC, ag0aep6g wrote: On 20.04.2016 23:59, Alex Parrill wrote: [...] That's not assigning the elements of a void[]; it's just changing what the slice points to and adjusting the length, like doing `void* ptr = some

Re: Handling arbitrary char ranges

2016-04-20 Thread Alex Parrill via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 22:44:37 UTC, ag0aep6g wrote: On 20.04.2016 23:59, Alex Parrill wrote: On Wednesday, 20 April 2016 at 17:09:29 UTC, Matt Kline wrote: [...] First, you can't assign anything to a void[], for the same reason you can't dereference a void*. This includes the slice

Re: Compiler or Interpreter or Hybrid

2016-04-20 Thread thedeemon via Digitalmars-d-learn
On Thursday, 21 April 2016 at 02:06:00 UTC, newB wrote: How is D implemented? (Compiler, Interpreter and Hybrid). Can you please explain why? Generally D is a compiled language: you give the compiler some source code and it produces executable binary with native machine code. Then you ca

Re: Adding a float with all four elements of a float4

2016-04-20 Thread Straivers via Digitalmars-d-learn
On Thursday, 21 April 2016 at 01:49:19 UTC, Nicholas Wilson wrote: [...] you want to broadcast the rhs to a float4 and then adds them. Can you post the errors (if any) you get during compilation. Urgh, autocorrect. That should be addps them. I get a "Error: floating point constant expressi

Compiler or Interpreter or Hybrid

2016-04-20 Thread newBeeee via Digitalmars-d-learn
How is D implemented? (Compiler, Interpreter and Hybrid). Can you please explain why?

Re: Adding a float with all four elements of a float4

2016-04-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 21 April 2016 at 01:48:15 UTC, Nicholas Wilson wrote: On Thursday, 21 April 2016 at 00:14:53 UTC, Straivers wrote: Hi, I want to make a utility wrapper around a core.simd.float4, and have been trying to make the following code work, but have been met with no success. [...] yo

Re: Adding a float with all four elements of a float4

2016-04-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 21 April 2016 at 00:14:53 UTC, Straivers wrote: Hi, I want to make a utility wrapper around a core.simd.float4, and have been trying to make the following code work, but have been met with no success. [...] you want to broadcast the rhs to a float4 and then adds them. Can you

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

2016-04-20 Thread rcorre via Digitalmars-d-learn
On Thursday, 21 April 2016 at 01:18:14 UTC, rcorre wrote: On Wednesday, 20 April 2016 at 19:24:49 UTC, Chris wrote: 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

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

2016-04-20 Thread rcorre via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 19:24:49 UTC, Chris wrote: 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 s

Adding a float with all four elements of a float4

2016-04-20 Thread Straivers via Digitalmars-d-learn
Hi, I want to make a utility wrapper around a core.simd.float4, and have been trying to make the following code work, but have been met with no success. auto add(float rhs) { return __simd(XMM.ADDPS, lhs, rhs); } Then I tried auto add(float4 lhs, float rhs) { float4 tmp = [rhs, rhs,

VisualD + ZeroMQ

2016-04-20 Thread Chuck Moore via Digitalmars-d-learn
Hi Everyone, Preamble: We're a Win7+VisualStudio development environment. This question involves integrating the GitHub-based 'D-Programming-Deimos/ZeroMQ' package in a 'D' solution. Short form of issue: If anyone has compiled a D program using (say) zmq_ctx_new(), then I'd appreciate knowin

Re: Handling arbitrary char ranges

2016-04-20 Thread ag0aep6g via Digitalmars-d-learn
On 20.04.2016 23:59, Alex Parrill wrote: On Wednesday, 20 April 2016 at 17:09:29 UTC, Matt Kline wrote: [...] First, you can't assign anything to a void[], for the same reason you can't dereference a void*. This includes the slice assignment that you are trying to do in `buf[0..minLen] = remai

Re: Handling arbitrary char ranges

2016-04-20 Thread Alex Parrill via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 17:09:29 UTC, Matt Kline wrote: [...] First, you can't assign anything to a void[], for the same reason you can't dereference a void*. This includes the slice assignment that you are trying to do in `buf[0..minLen] = remainingData[0..minLen];`. Cast the buffe

Re: Handling arbitrary char ranges

2016-04-20 Thread ag0aep6g via Digitalmars-d-learn
On 20.04.2016 22:09, Matt Kline wrote: I'd rather not write my own cURL wrapper. Do you think it would be worthwhile starting a PR for Phobos to get it changed to ubyte[]? A reading of https://dlang.org/spec/arrays.html indicates the main difference is that that GC crawls void[], but I would thin

Re: VariantPointer

2016-04-20 Thread Nordlöw via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 18:40:58 UTC, Alex Parrill wrote: As for the GC, you're probably out of luck. Adding a global mask option is unlikely to work well if multiple libraries use it. So we need an optional block-local mask then! ;)

Re: Handling arbitrary char ranges

2016-04-20 Thread Matt Kline via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 20:00:58 UTC, ag0aep6g wrote: Maybe I've missed it, but you didn't say where the HTTP type comes from, did you? std.net.curl: https://dlang.org/phobos/std_net_curl.html#.HTTP (Sorry, I assumed that was a given since it's a standard library type. Poor assumption,

Re: VariantPointer

2016-04-20 Thread Nordlöw via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 16:08:32 UTC, Lass Safin wrote: core.memory.GC.setAttr can set attributes for a block of memory, with which you can set the attribute NO_SCAN, which as it implies, forces that no scan be done in the particular block of memory. This can be used to insure that the G

Re: Shallow copy object when type is know

2016-04-20 Thread Tofu Ninja via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 18:48:58 UTC, Alex Parrill wrote: On Wednesday, 20 April 2016 at 12:32:48 UTC, Tofu Ninja wrote: Is there a way to shallow copy an object when the type is known? I cant seem to figure out if there is a standard way. I can't just implement a copy function for the c

Re: Handling arbitrary char ranges

2016-04-20 Thread ag0aep6g via Digitalmars-d-learn
On 20.04.2016 21:48, Matt Kline wrote: I don't have an option here, do I? I assume HTTP.onSend doesn't take a `delegate size_t(ubyte[])` insetad of a `delegate size_t(void[])`, and that the former isn't implicitly convertible to the latter. Maybe I've missed it, but you didn't say where the HTT

Re: Handling arbitrary char ranges

2016-04-20 Thread Matt Kline via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 19:29:22 UTC, ag0aep6g wrote: Maybe use ubyte[] for the buffer type instead. I don't have an option here, do I? I assume HTTP.onSend doesn't take a `delegate size_t(ubyte[])` insetad of a `delegate size_t(void[])`, and that the former isn't implicitly convertibl

Re: Handling arbitrary char ranges

2016-04-20 Thread ag0aep6g via Digitalmars-d-learn
On 20.04.2016 19:09, Matt Kline wrote: 1. What is the idiomatic way to constrain the function to only take char ranges? One might naïvely add `is(ElementType!T : char)`, but that falls on its face due to strings "auto-decoding" their elements to dchar. (More on that later.) Well, string is not

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: VariantPointer

2016-04-20 Thread Alex Parrill via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 13:41:27 UTC, Nordlöw wrote: At https://github.com/nordlow/phobos-next/blob/master/src/variant_pointer.d I've implemented a pointer-only version of Variant called VariantPointer. I plan to use it to construct light-weight polymorphism in trie containers for D

Re: Shallow copy object when type is know

2016-04-20 Thread Alex Parrill via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 12:32:48 UTC, Tofu Ninja wrote: Is there a way to shallow copy an object when the type is known? I cant seem to figure out if there is a standard way. I can't just implement a copy function for the class, I need a generic solution. A generic class copy function

Re: Handling arbitrary char ranges

2016-04-20 Thread Alex Parrill via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 17:09:29 UTC, Matt Kline wrote: I'm doing some work with a REST API, and I wrote a simple utility function that sets an HTTP's onSend callback to send a string: [...] IO functions usually work with octets, not characters, so an extra encoding step is needed. F

Handling arbitrary char ranges

2016-04-20 Thread Matt Kline via Digitalmars-d-learn
I'm doing some work with a REST API, and I wrote a simple utility function that sets an HTTP's onSend callback to send a string: @property outgoingString(ref HTTP request, const(void)[] sendData) { import std.algorithm : min; request.contentLength = sendData.length; auto

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

2016-04-20 Thread rcorre via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 12:48:46 UTC, rcorre wrote: 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

Re: VariantPointer

2016-04-20 Thread Lass Safin via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 14:36:54 UTC, Nordlöw wrote: On Wednesday, 20 April 2016 at 13:41:27 UTC, Nordlöw wrote: At https://github.com/nordlow/phobos-next/blob/master/src/variant_pointer.d Further: What to do with fact that the GC will fail to scan VariantPointers? Can the GC be tw

Re: VariantPointer

2016-04-20 Thread Lass Safin via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 13:41:27 UTC, Nordlöw wrote: At https://github.com/nordlow/phobos-next/blob/master/src/variant_pointer.d I've implemented a pointer-only version of Variant called VariantPointer. [...] It safe to assume that `typeBits` most significant bits of a pointer on a

Re: VariantPointer

2016-04-20 Thread Nordlöw via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 13:41:27 UTC, Nordlöw wrote: At https://github.com/nordlow/phobos-next/blob/master/src/variant_pointer.d Further: What to do with fact that the GC will fail to scan VariantPointers? Can the GC be tweaked to mask out the type bits before scanning?

VariantPointer

2016-04-20 Thread Nordlöw via Digitalmars-d-learn
At https://github.com/nordlow/phobos-next/blob/master/src/variant_pointer.d I've implemented a pointer-only version of Variant called VariantPointer. I plan to use it to construct light-weight polymorphism in trie containers for D I'm currently writing. VariantPointer uses the top N-bits (

Re: DUB and static libs

2016-04-20 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 10:19:10 UTC, abad wrote: I have a project which is a mixture of D, C++ and C. I have used Make for build automation so far but would like to migrate to DUB. I have hard time figuring out what to do with C / C++ sections of the program. DUB seems to ignore (prob

Re: DUB and static libs

2016-04-20 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 13:12:54 UTC, Mike Parker wrote: "libs": [ "stdc++", "sid.a" ], Oh, if you're using DMD only you can also pass configure it using sourceFiles: "sourceFile": ["/path/to/libsid.a"] The first is the equivalant of: dmd -L-lsid main.d ... And the second: dmd ma

Re: Shallow copy object when type is know

2016-04-20 Thread Tofu Ninja via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 12:32:48 UTC, Tofu Ninja wrote: Is there a way to shallow copy an object when the type is known? I cant seem to figure out if there is a standard way. I can't just implement a copy function for the class, I need a generic solution. I feel like void shallow_copy

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

2016-04-20 Thread rcorre 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

Shallow copy object when type is know

2016-04-20 Thread Tofu Ninja via Digitalmars-d-learn
Is there a way to shallow copy an object when the type is known? I cant seem to figure out if there is a standard way. I can't just implement a copy function for the class, I need a generic solution.

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

2016-04-20 Thread rcorre via Digitalmars-d-learn
=== $ 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 status --- errorlevel 1 === I'm seeing the above trying to compi

DUB and static libs

2016-04-20 Thread abad via Digitalmars-d-learn
I have a project which is a mixture of D, C++ and C. I have used Make for build automation so far but would like to migrate to DUB. I have hard time figuring out what to do with C / C++ sections of the program. DUB seems to ignore (probably sensibly) everything but D source files. I compiled a