Re: core.sys.posix.setjmp unavailable for OS X?

2018-01-15 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jan 16, 2018 at 08:29:57AM +0100, Jacob Carlborg via Digitalmars-d-learn wrote: > On 2018-01-16 08:29, Jacob Carlborg wrote: > > > They're used to implement Objective-C exceptions on macOS 32bit and > > iOS. > > Forgot the second part: > > ... so I assume that means it works. [...] So

Re: core.sys.posix.setjmp unavailable for OS X?

2018-01-15 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-01-16 08:29, Jacob Carlborg wrote: They're used to implement Objective-C exceptions on macOS 32bit and iOS. Forgot the second part: ... so I assume that means it works. -- /Jacob Carlborg

Re: core.sys.posix.setjmp unavailable for OS X?

2018-01-15 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-01-15 20:37, H. S. Teoh wrote: It's probably just a matter of adding the appropriate prototypes / declarations to druntime. Provided that they actually work as advertised, of course. They're used to implement Objective-C exceptions on macOS 32bit and iOS. -- /Jacob Carlborg

Re: I want to transmit the class name and the member name in the method

2018-01-15 Thread Martin Nowak via Digitalmars-d-learn
On Monday, 15 January 2018 at 15:28:19 UTC, Martin Nowak wrote: More concise stuff is possible with heavy compile-time trickery (https://dpaste.dzfl.pl/cd375ac594cf) without incurring dreaded 1+N queries or even any unnecessary SELECT fields. foreach (u; db.select!User.where!"NOT

Re: Does it have an http2 server/client lib like in golang?

2018-01-15 Thread Martin Nowak via Digitalmars-d-learn
On Monday, 15 January 2018 at 18:07:24 UTC, Cergoo wrote: subj WIP but a bit stalled. https://github.com/vibe-d/vibe.d/tree/http2-botan-cleanup Unless you really need server-push of assets, HTTP/2 on a reverse proxy gets you the same performance benefits as well.

class initialization

2018-01-15 Thread Marc via Digitalmars-d-learn
in C# you can initilizate the class members like this: var foo = new Foo { a = 1, b = 2 }; I found something similar to structs in D: myStruct S = {a:1, b:2}; But can't figure out if D does have that for classes.

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

Trait compiles

2018-01-15 Thread Jiyan via Digitalmars-d-learn
Hello, is there anyway to do something like this: mixin template foo( exp) { static if(__traits(compiles, exp))exp; } Thanks :)

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

Re: How to imporve D-translation of these Python list comprehensions ?

2018-01-15 Thread Timon Gehr via Digitalmars-d-learn
On 15.01.2018 20:05, xenon325 wrote: I think, most clear code would be with tripple `foreach`, so I'll go with that. But probably someone will come up with something better and range-ier. Suggestion are welcome! import std.stdio, std.algorithm, std.range, std.array, std.conv, std.json,

Re: How to imporve D-translation of these Python list comprehensions ?

2018-01-15 Thread Timon Gehr via Digitalmars-d-learn
On 15.01.2018 22:51, Timon Gehr wrote: auto aa(R)(R r){     typeof(r.front[1])[typeof(r.front[0])] a;     foreach(x;r) a[x[0]] = x[1];     return a; } Actually, better to use std.array.assocArray. import std.stdio, std.algorithm, std.range, std.array, std.conv, std.json, std.typecons;

Re: How to imporve D-translation of these Python list comprehensions ?

2018-01-15 Thread Biotronic via Digitalmars-d-learn
On Monday, 15 January 2018 at 19:05:52 UTC, xenon325 wrote: I think, most clear code would be with tripple `foreach`, so I'll go with that. But probably someone will come up with something better and range-ier. I will admit clarity has suffered, but I like the brevity: import std.json :

Re: How to imporve D-translation of these Python list comprehensions ?

2018-01-15 Thread lobo via Digitalmars-d-learn
On Monday, 15 January 2018 at 19:05:52 UTC, xenon325 wrote: A workmate has recently shown this piece of code to show how nice Python is (we are mostly C and growing C++ shop): [...] Well if that is what they can do in Python I'd hate to see their C++! They have done a great job making

Re: How to imporve D-translation of these Python list comprehensions ?

2018-01-15 Thread Igor Shirkalin via Digitalmars-d-learn
On Monday, 15 January 2018 at 19:05:52 UTC, xenon325 wrote: A workmate has recently shown this piece of code to show how nice Python is (we are mostly C and growing C++ shop): dd = [dict(_name=k, **{a + str(i): aget(d, k, a) for a in aa for i, d in enumerate([srv1, srv2])}) for k in

Re: core.sys.posix.setjmp unavailable for OS X?

2018-01-15 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jan 15, 2018 at 07:06:42PM +, bpr via Digitalmars-d-learn wrote: > Is there a reason that it's unavailable on OS X when it works fine on > Linux? The functions exist on OS X, and it's easy enough to compile C > programs using setjmp there; but not D programs. I don't think I'm >

core.sys.posix.setjmp unavailable for OS X?

2018-01-15 Thread bpr via Digitalmars-d-learn
Is there a reason that it's unavailable on OS X when it works fine on Linux? The functions exist on OS X, and it's easy enough to compile C programs using setjmp there; but not D programs. I don't think I'm getting a betterC experience on the Mac. I'd also ask why the there are no D docs for

How to imporve D-translation of these Python list comprehensions ?

2018-01-15 Thread xenon325 via Digitalmars-d-learn
A workmate has recently shown this piece of code to show how nice Python is (we are mostly C and growing C++ shop): import json from itertools import chain srv1 = {'acs': {'ver': '1.2.3', 'rev': '6f2260d'}, 'cms': {'ver': '4.5', 'rev': 'b17a67e'}, 'ots': {'ver': '6.7.80', 'rev':

Does it have an http2 server/client lib like in golang?

2018-01-15 Thread Cergoo via Digitalmars-d-learn
subj

Re: Cannot use local lambda as parameter to non-global template

2018-01-15 Thread Nordlöw via Digitalmars-d-learn
On Monday, 15 January 2018 at 15:27:23 UTC, Meta wrote: void main() { auto arr = [1, 2, 3]; arr.remove!(_ => _ == 1); writeln(arr); } Or was that code meant as an example? The problem occurs when the templated function is a member of the struct `arr`. I've moved the algorithm

Re: Cannot use local lambda as parameter to non-global template

2018-01-15 Thread Ali Çehreli via Digitalmars-d-learn
On 01/15/2018 07:27 AM, Meta wrote: On Monday, 15 January 2018 at 13:55:57 UTC, Nordlöw wrote: The function `remove` is a templated member of a struct instance `x`. Can you give a bit more context? The following code does not cause a compile error: import std.stdio; import std.algorithm;

Re: String Type Usage. String vs DString vs WString

2018-01-15 Thread SimonN via Digitalmars-d-learn
On Monday, 15 January 2018 at 14:44:46 UTC, Adam D. Ruppe wrote: On Monday, 15 January 2018 at 06:18:27 UTC, SimonN wrote: D's foreach [...] will autodecode and silently iterate over dchar, not char, even when the input is string That's not true. foreach will only decode on demand: foreach(c;

Re: String Type Usage. String vs DString vs WString

2018-01-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, January 15, 2018 14:56:33 Kagamin via Digitalmars-d-learn wrote: > On Monday, 15 January 2018 at 06:18:27 UTC, SimonN wrote: > > D's foreach and D's ranges will autodecode and silently iterate > > over dchar, not char > > foreach doesn't do it silently, decoding must be requested from >

Re: What's equivalent to C#'s select?

2018-01-15 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 15 January 2018 at 15:24:50 UTC, Marc wrote: I just thought that filter() could be evaluated at compile time too, as others function that I've used so far. Sometimes I don't know if a native function can be evaluated at compile time until I do enum x = func(); Yeah, it takes some

Re: I want to transmit the class name and the member name in the method

2018-01-15 Thread Martin Nowak via Digitalmars-d-learn
On Friday, 5 January 2018 at 07:40:14 UTC, Brian wrote: auto db = new ORM; auto users = db.select(User).where(email.like("*@hotmail.com")).limit(10); Expression templates are a dead-end for any non-trivial queries. You have to embrace SQL to properly use RDMS, at the cost of beginners having

Re: Cannot use local lambda as parameter to non-global template

2018-01-15 Thread Meta via Digitalmars-d-learn
On Monday, 15 January 2018 at 13:55:57 UTC, Nordlöw wrote: Why do I get errors like template instance remove!((_) => _ == 1) cannot use local '__lambda5' as parameter to non-global template remove()(in K key) for x.remove!(_ => _ == 1); but not for x.remove!"a == 11"; ? How are

Re: What's equivalent to C#'s select?

2018-01-15 Thread Marc via Digitalmars-d-learn
On Monday, 15 January 2018 at 07:37:42 UTC, Simen Kjærås wrote: On Sunday, 14 January 2018 at 22:07:22 UTC, Marc wrote: thanks, can i use it at compile time as well? enum isMutableString(string field) = is(typeof(__traits(getMember, >C, field)) == string); static foreach(field;

Re: Cannot use local lambda as parameter to non-global template

2018-01-15 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-01-15 14:55, Nordlöw wrote: Why do I get errors like template instance remove!((_) => _ == 1) cannot use local '__lambda5' as parameter to non-global template remove()(in K key) for     x.remove!(_ => _ == 1); but not for     x.remove!"a == 11"; ? How are these two lambdas

Re: Using Postgres connection functions

2018-01-15 Thread Joe via Digitalmars-d-learn
On Monday, 15 January 2018 at 02:28:29 UTC, Matthias Klumpp wrote: In any case, please don't start another Postgres library and consider contributing to one of the existing ones, so that we maybe have one really awesome, 100% complete library at some point. If, on the other hand, your goal

Re: Cannot use local lambda as parameter to non-global template

2018-01-15 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 15 January 2018 at 13:55:57 UTC, Nordlöw wrote: Why do I get errors like template instance remove!((_) => _ == 1) cannot use local '__lambda5' as parameter to non-global template remove()(in K key) for x.remove!(_ => _ == 1); but not for x.remove!"a == 11"; ? How are

Re: String Type Usage. String vs DString vs WString

2018-01-15 Thread Kagamin via Digitalmars-d-learn
On Monday, 15 January 2018 at 06:18:27 UTC, SimonN wrote: D's foreach and D's ranges will autodecode and silently iterate over dchar, not char foreach doesn't do it silently, decoding must be requested from it by explicitly specifying element type, it can also encode this way.

Re: String Type Usage. String vs DString vs WString

2018-01-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 15 January 2018 at 06:18:27 UTC, SimonN wrote: D's foreach [...] will autodecode and silently iterate over dchar, not char, even when the input is string That's not true. foreach will only decode on demand: string s; foreach(c; s) { /* c is a char here, it goes over bytes */ }

Cannot use local lambda as parameter to non-global template

2018-01-15 Thread Nordlöw via Digitalmars-d-learn
Why do I get errors like template instance remove!((_) => _ == 1) cannot use local '__lambda5' as parameter to non-global template remove()(in K key) for x.remove!(_ => _ == 1); but not for x.remove!"a == 11"; ? How are these two lambdas different? The function `remove` is a

Re: String Type Usage. String vs DString vs WString

2018-01-15 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 15 January 2018 at 04:27:15 UTC, Jonathan M Davis wrote: On Monday, January 15, 2018 03:14:02 Tony via Digitalmars-d-learn wrote: On Monday, 15 January 2018 at 02:09:25 UTC, rikki cattermole wrote: > Unicode has three main variants, UTF-8, UTF-16 and UTF-32. > The size of a code