Re: Scenario: OpenSSL in D language, pros/cons

2014-05-05 Thread JR via Digitalmars-d
On Sunday, 4 May 2014 at 21:18:24 UTC, Daniele M. wrote: And then comes my next question: except for that malloc-hack, would it have been possible to write it in @safe D? I guess that if not, module(s) could have been made un-@safe. Not saying that a similar separation of concerns was not

Re: Scenario: OpenSSL in D language, pros/cons

2014-05-06 Thread JR via Digitalmars-d
On Monday, 5 May 2014 at 15:01:05 UTC, Andrei Alexandrescu wrote: On 5/5/14, 2:32 AM, JR wrote: On Sunday, 4 May 2014 at 21:18:24 UTC, Daniele M. wrote: And then comes my next question: except for that malloc-hack, would it have been possible to write it in @safe D? I guess that if not,

Re: D Language Version 3

2014-05-29 Thread JR via Digitalmars-d
On Thursday, 29 May 2014 at 08:50:38 UTC, Chris wrote: On Wednesday, 28 May 2014 at 22:48:22 UTC, Jonathan M Davis via Digitalmars-d wrote: Is this the first attempt at D Version 3? :-) Compiles to only ELF/DWARF headers!

Re: [OT] DConf socks

2014-06-10 Thread JR via Digitalmars-d
On Monday, 9 June 2014 at 20:37:57 UTC, Andrei Alexandrescu wrote: On 6/9/14, 12:56 PM, Justin Whear wrote: On Mon, 09 Jun 2014 12:18:08 -0700, Andrei Alexandrescu wrote: Hello, Someone at DConf left me a pair of handmade socks to pass to a coworker whom they didn't get to meet. I forgot

Re: [OT] DConf socks

2014-06-10 Thread JR via Digitalmars-d
On Tuesday, 10 June 2014 at 20:52:27 UTC, Walter Bright wrote: On 6/10/2014 1:18 AM, JR wrote: Missed opportunity to use std.socks.assumeMine and netting yourself an extra pair... The trouble with the socks datatype is the destructor is randomly run on only one of each pair. Sock[2]

Re: foreach

2014-06-13 Thread JR via Digitalmars-d
On Thursday, 12 June 2014 at 16:59:34 UTC, bearophile wrote: Nick Treleaven: there is also this usage: foreach (i, _; range){...} I think this is a very uncommon usage. I think I have not used it so far. Would enforcing immutability there be a breaking change? foreach (/*immutable*/

Re: Perlin noise benchmark speed

2014-06-20 Thread JR via Digitalmars-d
On Friday, 20 June 2014 at 15:24:38 UTC, bearophile wrote: If I add this import in Noise2DContext.getGradients the run-time decreases a lot (I am now just two times slower than gcc with -Ofast): import core.stdc.math: floor; Bye, bearophile Was just about to post that if I cheat and

Re: std.math performance (SSE vs. real)

2014-06-30 Thread JR via Digitalmars-d
On Monday, 30 June 2014 at 17:01:07 UTC, Walter Bright wrote: 2. My business accounts have no notion of fractional cents, so there's no reason to confuse the bookkeeping with them. .1 BTC

Re: Random points from a D n00b CTO

2014-07-15 Thread JR via Digitalmars-d
On Tuesday, 15 July 2014 at 09:24:14 UTC, Vic wrote: To illustrate point on D complexity: https://d262ilb51hltx0.cloudfront.net/max/800/1*_gRpHqzB-1zbG17jdxGPaQ.png It appears that it mission is to be Java, vs a system lang. hth Maybe I misunderstand the term, but it seems to me that a

Re: Weird…

2014-07-15 Thread JR via Digitalmars-d
On Tuesday, 15 July 2014 at 16:56:27 UTC, Russel Winder via Digitalmars-d wrote: Funny how when people send big smiles, they always mention D? :-D :D D:

Re: Livestreaming DConf?

2014-05-12 Thread JR via Digitalmars-d-announce
On Monday, 12 May 2014 at 07:21:39 UTC, Dicebot wrote: Will that also mean that we won't need to wait several months for all videos to be published? :) This is an interesting point. If memory serves last time one video was released per week, meaning that reddit/hn readers could properly

Re: number formatting

2014-04-20 Thread JR via Digitalmars-d-learn
On Sunday, 20 April 2014 at 12:53:11 UTC, steven kladitis wrote: Note sure if you can edit messages once sent. $13,456.67 245,678,541 On Sunday, 20 April 2014 at 12:50:52 UTC, steven kladitis wrote: How do you format numbers to have things like. Leading $ or , or CR with or without leading

Allocation-free message passing?

2014-05-02 Thread JR via Digitalmars-d-learn
I'm trying to impose limits upon myself to, well, learn. Currently I'm exploring ways to avoid allocations -- but my program is running in three threads with considerable amounts of message passing between them. Unless I'm misinterpreting my callgraph, std.concurrency.MessageBox contains a

Re: The writeln() function's args can't be [一 ,二]?

2014-05-06 Thread JR via Digitalmars-d-learn
On Tuesday, 6 May 2014 at 09:43:10 UTC, FrankLike wrote: Hi,everyone, I find the The writeln() function's args can't be [一 ,二]? why? Thank you. Frank. The problem is that you have a wide-character comma (,) there. This works: void main() { writeln([一, 二]); }

Templating everything? One module per function/struct/class/etc, grouped by package?

2014-05-12 Thread JR via Digitalmars-d-learn
Given that... 1. importing a module makes it compile the entirety of it, as well as whatever it may be importing in turn 2. templates are only compiled if instantiated 3. the new package.d functionality ...is there a reason *not* to make every single function/struct/class separate submodules

Re: Templating everything? One module per function/struct/class/etc, grouped by package?

2014-05-12 Thread JR via Digitalmars-d-learn
On Monday, 12 May 2014 at 09:16:53 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: Well, that would be a lot of extraneous files, which would be very messy IMHO. It also makes it much harder to share private functionality, because everything is scattered across modules - you'd be force to

Re: receiveTimeout minimum reasonable timeout value?

2014-05-15 Thread JR via Digitalmars-d-learn
On Thursday, 15 May 2014 at 18:15:46 UTC, Charles Hixson via Digitalmars-d-learn wrote: Duration can be specified in nanoseconds, but does it make any sense to have a value of 1 nanosecond? 0? My desire is to check whether a message is in the queue, and then either move it local to the

Re: Permutation Sort Algorithm Very Slow

2014-06-08 Thread JR via Digitalmars-d-learn
On Sunday, 8 June 2014 at 08:44:42 UTC, monarch_dodra wrote: of. If you want to use a bad algorithm, you could also go for bogosort: void main() { auto data = [2, 7, 4, 3, 5, 1, 0, 9, 8, 6, -1]; while (!isSorted(data)) randomShuffle(data); data.writeln; } I'm partial to

Re: stack trace output on exception

2014-07-08 Thread JR via Digitalmars-d-learn
On Tuesday, 8 July 2014 at 07:11:26 UTC, Stephan Schiffels wrote: Hi, I am using dmd with version: DMD64 D Compiler v2.065-devel-db2a73d My program throws a custom exception with a custom error message at some point. The stack trace (below) is very uninformative. Is there a way to output

Re: Capture offset of matches in std.regex.matchAll?

2014-07-08 Thread JR via Digitalmars-d-learn
On Monday, 7 July 2014 at 21:32:30 UTC, JD wrote: I'm using a compile time regex to find some tags in an input string. Is it possible to capture the offset of the matches in some way? Otherwise I have to calculate the offsets myself by iterating over the results of matchAll. Thanks, Jeroen I

Re: Opinions: The Best and Worst of D (for a lecture/talk I intend to give)

2014-07-10 Thread JR via Digitalmars-d-learn
On Monday, 7 July 2014 at 23:47:26 UTC, Aerolite wrote: So, if you would be so kind, give me a bullet list of the aspects of D you believe to be good, awesome, bad, and/or ugly. If you have the time, some code examples wouldn't go amiss either! Try not to go in-depth to weird edge cases -

Re: Insert a char in string

2014-07-11 Thread JR via Digitalmars-d-learn
On Thursday, 10 July 2014 at 19:33:15 UTC, simendsjo wrote: On 07/10/2014 06:05 PM, Alexandre wrote: I have a string X and I need to insert a char in that string... auto X = 100; And I need to inser a ',' in position 3 of this string..., I try to use the array.insertInPlace,

Appender.put return value

2014-07-24 Thread JR via Digitalmars-d-learn
Is there a big reason why Appender.put doesn't return this? http://dpaste.dzfl.pl/bb840e3e349e It would allow for convenient chaining. :

Re: Template instantiation and string vs const char[]

2014-09-03 Thread JR via Digitalmars-d-learn
On Wednesday, 3 September 2014 at 05:18:42 UTC, Jason den Dulk wrote: [...] While not really answering your question, I believe the idiomatic way is to use enum here instead of string/char[]. Conjecture: strings are final but the symbol can be redirected to point to new arrays, such as

Re: how to call class' template constructor

2014-10-12 Thread JR via Digitalmars-d-learn
On Sunday, 12 October 2014 at 19:46:41 UTC, ketmar via Digitalmars-d-learn wrote: Hello. please, how to call template constructor of a class? it's completely escaped my mind. i.e. i have this class: class A { this(alias ent) (string name) { ... } } and i want to do:

Re: printing array of strings with writefln?

2014-11-16 Thread JR via Digitalmars-d-learn
On Sunday, 16 November 2014 at 14:16:55 UTC, Artem Tarasov wrote: writefln(%(%s-%), [a, b, c]) doesn't print the intended a-b-c but surrounds each string with double quotes - a-b-c, which I find inconsistent with the fact that writefln(%s, a string) prints the string without any quotes. How

writefln patterns with mismatching compile-time known number of arguments

2015-04-12 Thread JR via Digitalmars-d-learn
I was chatting with a friend and showed him how printf(%s) printed random memory in C, whereas writefln(%s) in D threw an Exception upon execution. It's probably not a completely fair comparison but that's a different topic. I admit to being confused as to why it passed compilation at all in

Re: Help with Concurrency

2015-11-04 Thread JR via Digitalmars-d-learn
On Tuesday, 3 November 2015 at 23:16:59 UTC, bertg wrote: Running the following code I get 3 different tid's, multiple "sock in" messages printed, but no receives. I am supposed to get a "received!" for each "sock in", but I am getting hung up on "receiving...". [...] while (true)

Re: Help with Concurrency

2015-11-04 Thread JR via Digitalmars-d-learn
On Wednesday, 4 November 2015 at 16:49:59 UTC, JR wrote: [...] And my indentation and brace-balancing there is wrong. Shows how dependent I've become on syntax highlighting. import core.time; import std.concurrency; bool received = receiveTimeout(1.seconds,

Re: benchmark on binary trees

2015-12-05 Thread JR via Digitalmars-d-learn
On Friday, 4 December 2015 at 14:06:26 UTC, Alex wrote: [...] hoping it would be faster. This was not the case. Why? [...] Is there anything else to improve performance significantly? Profile. Profile profile profile. Callgrind. Find bottlenecks instead of guessing them.

Re: alias butAtLeast = max; 5.butAtLeast(6);

2015-12-12 Thread JR via Digitalmars-d-learn
On Saturday, 12 December 2015 at 12:43:36 UTC, SimonN wrote: DMD v2.069.2-b1 on Linux. import std.algorithm; int a = max(5, 6);// works, a == 6 int b = max!(int, int)(5, 6); // works, manual instantiation int c = 5.max(6); // works, UFCS call I would

New forum mobile appearance feedback

2016-01-22 Thread JR via Digitalmars-d-learn
Unsure where else to post this, since it feels like it would intrude on the more serious discussions in the main D forum. The new forum design is overall great, but it really doesn't work well on mobile devices. Coupled with field padding the font is simply too large. (This holds for the

Re: How to return a const handle (view) to a mutable member of an agregate

2016-03-13 Thread JR via Digitalmars-d-learn
On Sunday, 13 March 2016 at 20:13:03 UTC, Basile B. wrote: On Sunday, 13 March 2016 at 20:10:57 UTC, Basile B. wrote: [...] Basile beat me to it. Yes, ref const(Array!T) accessor. http://dpaste.dzfl.pl/cb2bc5cf9917

Re: Obtaining argument names in (variadic) functions

2016-03-18 Thread JR via Digitalmars-d-learn
On Wednesday, 16 March 2016 at 20:43:09 UTC, jkpl wrote: I try to anticipate the reason why you want this. [...] I use something *kinda* sort of similar in my toy project to print all fields of a struct, for debugging purposes when stuff goes wrong. Getting the names of the member variables

Re: Obtaining argument names in (variadic) functions

2016-03-19 Thread JR via Digitalmars-d-learn
On Wednesday, 16 March 2016 at 20:24:38 UTC, data pulverizer wrote: Hi D gurus, is there a way to obtain parameter names within the function body? I am particularly interested in variadic functions. Something like: void myfun(T...)(T x){ foreach(i, arg; x) writeln(i, " : ",

Re: Obtaining argument names in (variadic) functions

2016-03-20 Thread JR via Digitalmars-d-learn
On Thursday, 17 March 2016 at 14:12:38 UTC, Edwin van Leeuwen wrote: On Thursday, 17 March 2016 at 13:53:00 UTC, JR wrote: Interesting, any idea if it is possible to do assignment within template.. Either: printVars!(int abc=5,string def="58")(); or something like

Re: Obtaining argument names in (variadic) functions

2016-03-19 Thread JR via Digitalmars-d-learn
On Thursday, 17 March 2016 at 11:52:13 UTC, Edwin van Leeuwen wrote: On Wednesday, 16 March 2016 at 20:53:42 UTC, JR wrote: void printVars(Args...)() if (Args.length > 0) { import std.stdio : writefln; foreach (i, arg; Args) { writefln("%s\t%s:\t%s", typeof(Args[i]).stringof,

Re: efficient and safe way to iterate on associative array?

2016-03-04 Thread JR via Digitalmars-d-learn
On Friday, 4 March 2016 at 14:16:55 UTC, Minas Mina wrote: On Friday, 4 March 2016 at 13:53:22 UTC, aki wrote: I think what you can do is extract its contents to an array, iterate it and modify it as you like, and then insert back to another associative array. I don't think it's efficient but

Re: How do I extend an enum?

2016-03-19 Thread JR via Digitalmars-d-learn
On Saturday, 19 March 2016 at 17:41:29 UTC, Lass Safin wrote: On Saturday, 19 March 2016 at 17:40:27 UTC, Lass Safin wrote: Why: enum Base { A, B, } enum Derived : Base { C, // Gives error, says it can't implicitly convert expression to Base. D = 1, // Same error E =

Re: No property error message

2016-03-19 Thread JR via Digitalmars-d-learn
On Saturday, 19 March 2016 at 18:36:10 UTC, ric maicle wrote: I got an error message with the following code saying: Error: no property 'length' for type 'int[string]' Shouldn't the error message say 'length()'? ~~~ import std.stdio; void main() { int[string] a; a["one"] = 1;