Re: Password Storage

2016-01-03 Thread sarn via Digitalmars-d-learn
On Friday, 27 November 2015 at 00:17:34 UTC, brian wrote: 3) pre- or post-pend the salt to the password entered (apparently there is a difference??) Sorry to revive an old thread, but I wrote a blog post about this question:

Re: Functions that return type

2016-01-16 Thread sarn via Digitalmars-d-learn
On Saturday, 16 January 2016 at 21:22:15 UTC, data pulverizer wrote: Is it possible to create a function that returns Type like typeof() does? Something such as: Type returnInt(){ return int; } A type itself isn't a runtime value. I think the closest thing is a TypeInfo object:

Re: how to mark an extern function @nogc?

2016-07-12 Thread sarn via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 14:04:55 UTC, Seb wrote: D is entirely driven by highly motivated volunteers. (this will change soon with the new D foundation) I for one welcome our new D Foundation overlords.

Re: capture stdout or stderr

2017-02-02 Thread sarn via Digitalmars-d-learn
On Wednesday, 1 February 2017 at 01:08:19 UTC, Emil wrote: is it possible to intercept the STDOUT or STDERR and capture the output into a variable ? some pseudocode to explain what I mean string[] output_buffer; stdout.capture_to(output_buffer); writeln("test 1"); # not printed

Re: Safely moving structs in D

2017-01-23 Thread sarn via Digitalmars-d-learn
On Monday, 23 January 2017 at 22:26:58 UTC, bitwise wrote: Is it ok to memcpy/memmove a struct in D? Quote from here: https://dlang.org/spec/garbage.html "Do not have pointers in a struct instance that point back to the same instance. The trouble with this is if the instance gets moved in

Re: General performance tips

2017-01-23 Thread sarn via Digitalmars-d-learn
On Monday, 23 January 2017 at 12:13:30 UTC, albert-j wrote: Well it is actually ODE solver from Numerical recipes (originally in C++) that I am trying to do in D. Code translation seems very straightforward. Maybe there's someone around who has done that already? There's not much object

Re: Hello, folks! Newbie to D, have some questions!

2017-02-18 Thread sarn via Digitalmars-d-learn
On Saturday, 18 February 2017 at 21:09:20 UTC, ag0aep6g wrote: Also, some threads online mention that if we do turn off GC, some of the core std libraries may not fully work. Is this presumption also correct? Yes. Whenever a std function returns a new string or some such it's going to be

Re: Hello, folks! Newbie to D, have some questions!

2017-02-18 Thread sarn via Digitalmars-d-learn
On Saturday, 18 February 2017 at 20:15:55 UTC, timmyjose wrote: Hello folks, Hi :) 2. I am more interested in learning D as a pure systems programming language so that I can develop my own tools (not looking to develop an OS, just some grep-scale tools to start off with). In that regard, I

Re: Why do static arrays affect executable size?

2017-02-10 Thread sarn via Digitalmars-d-learn
On Friday, 10 February 2017 at 15:12:28 UTC, Jonathan M Davis wrote: Module-level and static variables all get put in the executable. So, declaring a static array like that is going to take up space. A dynamic array would do the same thing if you gave it a value of that size. The same thing

Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-02-28 Thread sarn via Digitalmars-d-learn
On Tuesday, 28 February 2017 at 07:41:36 UTC, Christian Köstlin wrote: As I understand the only difference between assert and enforce is, that assert is not compiled into releases? Thanks! Christian Pretty much so. The intention is that assert means something that's supposed to be true

Re: pure functions

2016-09-12 Thread sarn via Digitalmars-d-learn
On Tuesday, 13 September 2016 at 03:33:04 UTC, Ivy Encarnacion wrote: Can pure functions throw exceptions on its arguments? You can throw exceptions for whatever reasons from a function marked pure: void foo() pure { throw new Exception("nope"); } void main() { foo(); }

Re: vibe.d maxRequestSize

2016-09-15 Thread sarn via Digitalmars-d-learn
I hope this isn't too obvious, but I have to ask because it's such a common gotcha: Are you reverse proxying through a server like nginx by any chance? There are default request size limits there. (For nginx specifically, it's this one:

Re: Can vibe d leverage existing web technologies?

2016-09-16 Thread sarn via Digitalmars-d-learn
On Friday, 16 September 2016 at 12:46:34 UTC, Martin Tschierschke wrote: The "only" problem is you have to build your layout twice, in php and as diet template. :-( You also have to manage URLs across different codebases. I'd recommend against splitting up a frontend like that because it

Re: What blogs about D do you read?

2016-09-20 Thread sarn via Digitalmars-d-learn
Don't forget the Planet D aggregator :) http://planet.dsource.org/ Here's my contribution: https://theartofmachinery.com/tags/dlang/

Re: Sockets and using them...

2016-11-06 Thread sarn via Digitalmars-d-learn
On Sunday, 6 November 2016 at 06:02:48 UTC, Era Scarecrow wrote: So I've got a project where I want to create basically a decentralized chat program where every program is a host and a client. When you connect all connections can go through to route the chat to everyone else. So to make

Re: Calling std.variant.visit from a pure function

2016-11-04 Thread sarn via Digitalmars-d-learn
On Friday, 4 November 2016 at 02:56:07 UTC, Paul Backus wrote: When I compile this (using DMD 2.069 on Debian Linux), I get an error saying that I can't call visit from a pure function. This is surprising, since all visit does (in theory) is call the provided functions, and all of _them_ are

Re: Parse a String given some delimiters

2016-10-30 Thread sarn via Digitalmars-d-learn
On Sunday, 30 October 2016 at 20:50:47 UTC, Alfred Newman wrote: Hello, I'm migrating some Python code to D, but I stuck at a dead end... Sorry to provide some .py lines over here, but I got some doubts about the best (fastest) way to do that in D. The "splitter" generic function sounds

Re: general questions about static this() at module level

2016-10-30 Thread sarn via Digitalmars-d-learn
On Monday, 31 October 2016 at 04:35:35 UTC, WhatMeWorry wrote: First, are there any other languages that has this feature? The few I know, certainly don't. I've seen hacks to do the same thing in C++. They're not pretty, though. And how would you compare and contrast these this(s) with

Re: [Semi-OT] I don't want to leave this language!

2016-12-05 Thread sarn via Digitalmars-d-learn
On Monday, 5 December 2016 at 17:18:25 UTC, e-y-e wrote: Currently I have been learning D for about a year and a half. This may seem like a short time, but this is the longest I have stuck with any language. I have only been learning for 4 years and I am currently in university studying first

Re: How to get dub to work when I have dlang installed in custom directory?

2017-03-03 Thread sarn via Digitalmars-d-learn
On Friday, 3 March 2017 at 20:35:04 UTC, Jamal wrote: I have no idea what is is wrong and or how to fix it. Any help? It would be the alias. When you're running dmd from your shell, you're using an alias that includes a bunch of flags to make dmd work. When dub runs, it'll run the dmd

Re: TLS

2017-03-10 Thread sarn via Digitalmars-d-learn
On Friday, 10 March 2017 at 19:24:29 UTC, bauss wrote: Mark your variables with __gshared. I would say shred, but it has some restrictions to it, where __gshared is the equivalent to global variables in C. immutable variables are also not put in TLS.

Re: Writing pattern matching macros in D.

2017-03-05 Thread sarn via Digitalmars-d-learn
On Monday, 6 March 2017 at 02:20:02 UTC, Deech wrote: Hi all, I've been reading up on D's metaprogramming features and was wondering if it was possible to use them to add pattern matching to the language as a macro. The template mixin feature seems to require putting the new syntax in

Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-02-27 Thread sarn via Digitalmars-d-learn
On Monday, 27 February 2017 at 19:26:06 UTC, Christian Köstlin wrote: How can I make sure, that the calculations are done at compile time? If you ever have doubts, you can always use something like this to check: assert (__ctfe);

Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-02-27 Thread sarn via Digitalmars-d-learn
On Tuesday, 28 February 2017 at 00:20:05 UTC, sarn wrote: On Monday, 27 February 2017 at 19:26:06 UTC, Christian Köstlin wrote: How can I make sure, that the calculations are done at compile time? If you ever have doubts, you can always use something like this to check: assert (__ctfe);

Re: std.math module

2017-08-06 Thread sarn via Digitalmars-d-learn
On Sunday, 6 August 2017 at 23:33:26 UTC, greatsam4sure wrote: import std.math; import std.stdio; cos(90*PI/180) = -2.7e-20 instead of zero. I will appreciate any help. thanks in advance. tan(90*PI/180) = -3.689e+19 instead of infinity. What is the best way to use this module That's just

Re: BetterC and TypeInfo Question

2017-06-22 Thread sarn via Digitalmars-d-learn
Currently a lot of language features generate dependencies on TypeInfo, arguably more than needed, but this is changing. Some examples are in this DConf 2017 talk: https://www.youtube.com/watch?v=endKC3fDxqs Also, the way the language is designed right now, all modules are responsible for

Re: ESR on post-C landscape

2017-11-16 Thread sarn via Digitalmars-d-learn
On Thursday, 16 November 2017 at 11:52:45 UTC, Ola Fosheim Grostad wrote: On Thursday, 16 November 2017 at 11:24:09 UTC, codephantom I would never say OO itself is a failure. But the idea that is should be the 'primary focus of program design' .. I think that is a failure...and I think that

Re: ESR on post-C landscape

2017-11-16 Thread sarn via Digitalmars-d-learn
On Tuesday, 14 November 2017 at 09:43:07 UTC, Ola Fosheim Grøstad wrote: ESR got famous for his cathedral vs bazaar piece, which IMO was basically just a not very insightful allegory over waterfall vs evolutionary development models, but since many software developers don't know the basics of

Re: using wkhtmltopdf with D

2018-05-27 Thread sarn via Digitalmars-d-learn
On Monday, 28 May 2018 at 01:28:10 UTC, Dr.No wrote: What's likely the reason of the crash? mismatch between D and C memory alignment? From an ABI point of view, the raw pointers won't care about the memory structure they point to. The function call is the only thing that depends on the

Re: How can I point an array to existing data in memory while using Better C?

2018-07-08 Thread sarn via Digitalmars-d-learn
On Sunday, 8 July 2018 at 21:11:53 UTC, Stijn Herreman wrote: On Sunday, 8 July 2018 at 20:27:34 UTC, Stijn Herreman wrote: I should point out that I only have a vague idea of what I'm doing, I tried things until it compiled and worked (at first glance). If there are any docs that properly

Re: Strange behavior using array of structures

2018-04-04 Thread sarn via Digitalmars-d-learn
On Wednesday, 4 April 2018 at 10:00:18 UTC, Orfeo wrote: foreach (l; log) { l.run; } Try making this "foreach (ref l; log) {". Structs are value types in D, so by default they're copied when you assign them to another variable (in this case l). That means run() is

Re: How does buffering actually work?

2019-02-28 Thread sarn via Digitalmars-d-learn
On Thursday, 28 February 2019 at 21:17:23 UTC, Cleverson Casarin Uliana wrote: It works almost perfectly, except that it doesn't wait for my first Enter after printing "First name: value1". Rather, it prints both "First name: value1" and "First name: value2" together on the same line, then it

Re: Should D file end with newline?

2019-02-16 Thread sarn via Digitalmars-d-learn
On Friday, 15 February 2019 at 13:14:47 UTC, Patrick Schluter wrote: A lots of fgets() based tools on Unix systems fail to read the last line if it doesn't contain a line feed character at the end. Afaicr glibc implementation does not have that problem but a lot of other standard C libs do.

Re: Should D file end with newline?

2019-02-09 Thread sarn via Digitalmars-d-learn
On Saturday, 9 February 2019 at 21:19:27 UTC, Victor Porton wrote: ISO C++ specifies that the C++ file must end with a newline. Should D file end with newline, too? I'm sure you could mostly get away without one, but POSIX says that all text files should end with a newline. There are some

Re: Should D file end with newline?

2019-02-12 Thread sarn via Digitalmars-d-learn
On Tuesday, 12 February 2019 at 20:03:09 UTC, Jonathan M Davis wrote: So, I'd say that it's safe to say that dmd The whole thing just seems like a weird requirement that really shouldn't be there, Like I said in the first reply, FWIW, it's a POSIX requirement. Turns out most tools don't care

Re: What are some ways to get more strict type-checking?

2019-05-05 Thread sarn via Digitalmars-d-learn
On Monday, 6 May 2019 at 02:02:52 UTC, Devin wrote: Recently, I poorly refactored some code, which introduced an obvious bug. But to my astonishment, the broken code compiled without any warnings or notifications. A minimum example is shown below: alias ID = uint; ... alias doesn't

Re: Linking D Runtime

2019-09-03 Thread sarn via Digitalmars-d-learn
On Saturday, 24 August 2019 at 02:10:19 UTC, Jonathan Levi wrote: I would love a more portable solution though. This should work for now. How are you building the D code? It should be possible to build a library (with -lib and/or -shared) that statically includes the runtime and Phobos.

Re: canFind all elements in a array.

2020-11-10 Thread sarn via Digitalmars-d-learn
On Tuesday, 10 November 2020 at 08:19:15 UTC, Vino wrote: foreach(i; data2[]) { if(data1[].canFind(i[0])) { writeln(i[1]); } } This is iterating over all the elements in data2 and outputting some of them, so the output will never be longer than data2. It looks like you want to

Re: Druntime without pthreads?

2020-10-20 Thread sarn via Digitalmars-d-learn
On Tuesday, 20 October 2020 at 16:58:12 UTC, Severin Teona wrote: Hi guys. I have a curiosity, regarding [1] - I had encountered some "undefined reference" errors when trying to link the druntime (compiled for an embedded architecture) without some implementation of the POSIX thread calls

Re: GC memory fragmentation

2021-04-16 Thread sarn via Digitalmars-d-learn
On Tuesday, 13 April 2021 at 12:30:13 UTC, tchaloupka wrote: Some kind of GC memory dump and analyzer tool as mentioned `Diamond` would be of tremendous help to diagnose this.. I've used bpftrace to do some of that stuff: https://theartofmachinery.com/2019/04/26/bpftrace_d_gc.html