Re: Erasing passwords from ram?

2019-05-09 Thread Nick Sabalausky via Digitalmars-d-learn
On Tuesday, 30 April 2019 at 08:15:15 UTC, Dukc wrote: I am currently programming a server. So I got the idea that after I've generated all the hashes I need from a password, I want to erase it from RAM before discarding it, just to be sure it won't float around if the server memory is exposed

Recommendations for best JSON lib?

2019-04-20 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
I only need to read arbitrary JSON data, no need for writing/(de)serialization.

Re: Cross compile windows programs on linux

2018-08-24 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 08/24/2018 12:30 PM, John Burton wrote: On Friday, 24 August 2018 at 15:26:30 UTC, kinke wrote: On Friday, 24 August 2018 at 13:10:40 UTC, John Burton wrote: Is in the subject. Are there any cross compilers that will run on a linux system but compile D code using Win32 into a windows .exe

Re: Generically call a function on Variant's payload?

2018-08-21 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 08/21/2018 03:27 PM, Steven Schveighoffer wrote: If you examine how the code for variant works, it's quite clever. It establishes a "handler" that is generated with full compile-time type info available when the value is *assigned*, but then cast to a function taking a void pointer and an

Re: Generically call a function on Variant's payload?

2018-08-21 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 08/21/2018 03:03 AM, Nicholas Wilson wrote: On Monday, 20 August 2018 at 00:27:04 UTC, Nick Sabalausky (Abscissa) wrote: Suppose I've wrapped a Variant in a struct/class which ensures the Variant *only* ever contains types which satisfy a particular constraint (for example: isInputRange

Re: Generically call a function on Variant's payload?

2018-08-21 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 08/20/2018 10:57 PM, Jonathan M Davis wrote: Runtime reflection is theoretically possible in D, but it requires generating the appropriate stuff for every type involved so that the runtime stuff has something to work with. Java built all of that into the language and has the JVM to boot,

Re: Generically call a function on Variant's payload?

2018-08-20 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 08/20/2018 04:34 PM, Jonathan M Davis wrote: foreach(T; TypesThatVariantHolds) Yea, that's what I would've just done, but I wanted to support user-created types not already known to my library. You can't just call functions on completely unknown types, because the compiler

Re: Generically call a function on Variant's payload?

2018-08-20 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 08/19/2018 11:31 PM, Paul Backus wrote: You are basically reinventing OOP here. Yes, I am. Deliberately, in fact. Class inheritance is my backup plan, though. My use-case is actually very, very similar to std.digest: There are various benefits to using a template-and-constraint based

Re: Generically call a function on Variant's payload?

2018-08-19 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 08/19/2018 10:23 PM, Jonathan M Davis wrote: On Sunday, August 19, 2018 6:33:06 PM MDT Nick Sabalausky (Abscissa) via Digitalmars-d-learn wrote: Maybe something involving using Variant.coerce to convert the payload to a single common type? Not sure how I would do that though. You could

Re: Generically call a function on Variant's payload?

2018-08-19 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 08/19/2018 08:27 PM, Nick Sabalausky (Abscissa) wrote: Suppose I've wrapped a Variant in a struct/class which ensures the Variant *only* ever contains types which satisfy a particular constraint (for example: isInputRange, or hasLength, etc...). Is there a way to call a function (ex

Generically call a function on Variant's payload?

2018-08-19 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
Suppose I've wrapped a Variant in a struct/class which ensures the Variant *only* ever contains types which satisfy a particular constraint (for example: isInputRange, or hasLength, etc...). Is there a way to call a function (ex: popFront) on the Variant, *without* knowing ahead of time all

Re: D's type declarations seem to read right to left.

2018-03-21 Thread Nick Sabalausky via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 20:07:09 UTC, tipdbmp wrote: D's type declarations seem to read right to left. int an_integer; int[10] an_array_of_10_integers; int[10]* a_pointer_to_an_array_of_10_integers = _array_of_10_integers; int*[10] an_array_of_10_pointers_to_integers; int*[10]*

Re: docs/definition: !object

2018-03-08 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 03/08/2018 05:31 AM, Steven Schveighoffer wrote: On 3/8/18 1:00 AM, Nick Sabalausky (Abscissa) wrote: But are we CERTAIN that's all there is to it? I have a non-reduced situation right now where outputting the address of a class reveals a non-null address, and yet assert

Re: Can't "is null" an interface?!?! Incompatible types???

2018-03-08 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 03/08/2018 03:04 AM, Nick Sabalausky (Abscissa) wrote: Interesting. I was using vibe.d 'v0.8.3-rc.1' (which doesn't appear to work on run.dlang.io). But it does seem to work for me if I use 'v0.8.3-alpha.1'. I wonder what could have changed to result in this? https://github.com/vibe-d

Re: Can't "is null" an interface?!?! Incompatible types???

2018-03-08 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 03/08/2018 01:13 AM, Nicholas Wilson wrote: That does seem odd. --- /+dub.sdl: dependency "vibe-d" version="~>0.8.3-alpha.1" +/ import vibe.core.net; import std.stdio; TCPConnection mySocket; void main() {     auto b = mySocket is null;     writeln(b); } --- works fine on run.dlang.io

Re: docs/definition: !object

2018-03-07 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 03/08/2018 12:05 AM, ketmar wrote: Nick Sabalausky (Abscissa) wrote: I'm having trouble finding the documentation for what exactly the unary "not" operator does when applied to a class/interface object. Does this documentation exist somewhere? I know at least part of it involve

docs/definition: !object

2018-03-07 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
I'm having trouble finding the documentation for what exactly the unary "not" operator does when applied to a class/interface object. Does this documentation exist somewhere? I know at least part of it involves "is null", but I seem to remember hearing there was more to it than just that.

Can't "is null" an interface?!?! Incompatible types???

2018-03-07 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
- import vibe.core.net; TCPConnection mySocket; void main() { auto b = mySocket is null; } - That's giving me: - Error: incompatible types for (mySocket) is (null): TCPConnection and typeof(null) - WTF?!?!

Spawning a process: Can I "have my cake and eat it too"?

2018-03-01 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
I'd like to include this functionality in Scriptlike, but I don't know if it's even possible: Launch a process (spawnProcess, pipeShell, etc) so the child's stdout/stderr go to the parent's stdout/stderr *without* the possibility of them getting inadvertently reordered/reinterleaved when

Tuts/Aritcles: Incrementasl C++-to-D conversion?

2018-02-21 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
Are there any tutorials or articles out there for "getting started with converting a C++ codebase to D one module at a time?" Or at the very least: tips, tricks, lessions learned, from those who have come before.

Re: No line numbers in stack trace (again)

2017-12-12 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 12/05/2017 08:43 AM, Nordlöw wrote: If I get the following stack trace ___without line numbers___ (instead ??:?) what's missing? Linux stack trace line numbers have disappeard for me, too. Used to work. Very frustrating, and a royal PITA when dealing with unittests. Help would be

Re: git workflow for D

2017-12-04 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 12/03/2017 03:05 PM, bitwise wrote: I've finally started learning git, due to our team expanding beyond one person - awesome, right? PROTIP: Version control systems (no matter whether you use git, subversion, or whatever), are VERY helpful on single-person projects, too! Highly

Re: Struct inside a class: How to get outer?

2017-12-03 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 12/03/2017 03:46 AM, bauss wrote: On Sunday, 3 December 2017 at 07:38:47 UTC, Jonathan M Davis wrote: As I understand it, there is no outer for nested structs, only nested classes. So, you'll either have to use a nested class or explicitly pass a reference to the outer class to the nested

Struct inside a class: How to get outer?

2017-12-02 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
Is this even possible? My attempts: class Outer { struct Inner { void foo() { // Error: no property 'outer' for type 'Inner' Outer o = this.outer; // Error: cannot implicitly convert expression

gdc-6.3.0 on travis borked?

2017-11-30 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
When using gdc-6.3.0 on travis-ci, travis is reporting that it can't download the compiler: -- $ source "$(CURL_USER_AGENT="$CURL_USER_AGENT" bash install.sh gdc-6.3.0 --activate)" curl: (22) The requested URL returned error: 404 Not Found

Re: Range tee()?

2017-10-16 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 10/16/2017 03:30 AM, lobo wrote: On Monday, 16 October 2017 at 07:28:03 UTC, Nick Sabalausky (Abscissa) wrote: Does Phobos have a way to "tee" a range? For example, suppose you had something like this: [...] https://dlang.org/phobos/std_range.html#tee ? Ahh, thanks, I was on

Range tee()?

2017-10-16 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
Does Phobos have a way to "tee" a range? For example, suppose you had something like this: - // Do something with each file in a dir dirEntries(selectedDir, SpanMode.shallow) .filter!someFilterCriteria .doSomethingWithFile;

Re: problem with std.variant rounding

2017-05-02 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 05/02/2017 04:02 AM, Suliman wrote: I need co concatenate string with variant type (I am doing SQL query). What is the best way to put it? It's seems that if I am doing simple `replace` string sql = "..." sql.replace(`37.72308`, to!string(cargpspoint.lon)).replace(`55.47957`,

Re: GC: Understanding potential sources of false pointers

2017-04-24 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 04/22/2017 08:56 AM, Kagamin wrote: .rdata is fine, but afaik you have only strings there, the rest - .data, .bss, .tls will suffer the same issue. I don't know anything about the various object file sections. :/

Re: GC: Understanding potential sources of false pointers

2017-04-20 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 04/20/2017 09:00 AM, Kagamin wrote: https://issues.dlang.org/show_bug.cgi?id=15723 Hmm, so apparently embedded data (even if it's from a C lib) can also be a source of false pointers. Thanks, good to know.

Re: Can we disallow appending integer to string?

2017-04-20 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 04/19/2017 01:34 PM, Jonathan M Davis via Digitalmars-d-learn wrote: Yeah, which reduces the number of casts required when doing arithmetic on characters and thus reduces bugs there, Ugh, because apparently doing arithmetic on characters is such a common, important use-case in this modern

GC: Understanding potential sources of false pointers

2017-04-19 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
According to : "Registers, the stack, and any other memory locations added through the GC.addRange function are always scanned conservatively." 1. Can that be safely assumed to be a canonical list of all possible sources of false pointers? 2. What

Re: ddoc: Can I escape a colon?

2017-02-23 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 02/23/2017 10:36 PM, Adam D. Ruppe wrote: On Friday, 24 February 2017 at 02:50:27 UTC, Nick Sabalausky (Abscissa) wrote: What I'd kinda like to do is put together a D doc generator that uses, uhh, probably markdown. My dpldocs.info generator continues to progress and I'm almost ready

Re: Big Oversight with readln?

2017-02-23 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 02/23/2017 09:43 PM, Jonathan Marler wrote: I can't figure out how to make use of the full capacity of buffers that are allocated by readln. Take the example code from the documentation: // Read lines from $(D stdin) and count words void main() { char[] buf;

Re: ddoc: Can I escape a colon?

2017-02-23 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 02/23/2017 04:34 PM, Ali Çehreli wrote: (None of the following is tested.) a) Try using the following macro: COLON = And then use "Note$(COLON) Blah". Thanks, that works. c) Another option: NOTE = Note $0 Then use "$(NOTE Blah)" Actually, that's more or less what I was

Re: ddoc: Can I escape a colon?

2017-02-23 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 02/23/2017 04:49 PM, H. S. Teoh via Digitalmars-d-learn wrote: I'm becoming more and more convinced that software that tries to be smart ends up being even dumber than before. I've been convinced of that for a long time ;) Not just software either. Anything. My car does idiotic "smart"

Re: ddoc: Can I escape a colon?

2017-02-23 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 02/23/2017 04:51 PM, Adam D. Ruppe wrote: On Thursday, 23 February 2017 at 21:39:11 UTC, H. S. Teoh Apparently COLON is defined to be ':' in the default ddoc macros, so you needn't define it yourself. Oh yeah. Still, barf. Luckily in my case, the "Word:" part is already generated inside

ddoc: Can I escape a colon?

2017-02-23 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
Suppose I want ddoc output to include this line: -- Note: Blah blabbety blah -- But the colon causes "Note" to be considered a section header. Is there a way to escape the ":" so that it's displayed as expected, but doesn't trigger a section?

Partial arrays reclaimed?

2017-01-27 Thread Nick Sabalausky via Digitalmars-d-learn
Suppose an array is being used like a FIFO: --- T[] slice; // Add: slice ~= T(); // Remove: slice = slice[1..$]; --- Assuming of course there's no other references to the memory, as this gets used, does the any of the memory from the removed elements

Reflection: Order of fields guaranteed?

2016-10-21 Thread Nick Sabalausky via Digitalmars-d-learn
When using reflection to obtain the fields of a class/struct, is there any guarantee that the order is the same as the order the fields are defined?

Escaping ref to stack mem sometimes allowed in @safe?

2016-10-16 Thread Nick Sabalausky via Digitalmars-d-learn
This compiles. Is it supposed to? @safe ubyte[] foo() { ubyte[512] buf; auto slice = buf[0..$]; // Escaping reference to stack memory, right? return slice; } Or is the escaping reference detection not intended to be 100%? Or something else I'm missing? Should

Re: Phobos func for string -> enum member?

2016-10-13 Thread Nick Sabalausky via Digitalmars-d-learn
On 10/13/2016 07:14 PM, H. S. Teoh via Digitalmars-d-learn wrote: On Thu, Oct 13, 2016 at 07:11:15PM -0400, Nick Sabalausky via Digitalmars-d-learn wrote: I'm sure it'd be easy enough to write, but does phobos have a simple way to convert the name of an enum member from a runtime string

Phobos func for string -> enum member?

2016-10-13 Thread Nick Sabalausky via Digitalmars-d-learn
I'm sure it'd be easy enough to write, but does phobos have a simple way to convert the name of an enum member from a runtime string to the enum type? Ie, something like: enum Foobar { foo=1, bar } Foobar a = doesThisExistInPhobos!Foobar("foo"); I'm not finding anything like it in the docs,

Re: Custom test runner

2016-09-21 Thread Nick Sabalausky via Digitalmars-d-learn
On 09/21/2016 02:26 AM, Jacob Carlborg wrote: On 2016-09-21 07:51, Nick Sabalausky wrote: IIRC, there is some way to hook in and use a custom unittest-runner. How does one go about that? http://dlang.org/phobos/core_runtime.html#.Runtime.moduleUnitTester Cool, thanks. I got that to work

Re: Fully-qualified symbol disambiguation is deprecated???

2016-09-09 Thread Nick Sabalausky via Digitalmars-d-learn
On 09/09/2016 12:35 PM, pineapple wrote: On Friday, 9 September 2016 at 11:54:42 UTC, Steven Schveighoffer wrote: Can you demonstrate the issue? I have never heard of this. imports should work when done inside a function. -Steve Tried and failed to reproduce with a simple example, but any

Re: Fully-qualified symbol disambiguation is deprecated???

2016-09-09 Thread Nick Sabalausky via Digitalmars-d-learn
On 09/08/2016 06:22 PM, Nick Sabalausky wrote: On 09/08/2016 06:13 PM, Steven Schveighoffer wrote: On 9/8/16 6:02 PM, Nick Sabalausky wrote: I'm getting deprecation messages ("Package...not accessible here, perhaps add static import") when simply trying to use fully-qualified sy

Re: Fully-qualified symbol disambiguation is deprecated???

2016-09-08 Thread Nick Sabalausky via Digitalmars-d-learn
On 09/08/2016 06:22 PM, Nick Sabalausky wrote: On 09/08/2016 06:13 PM, Steven Schveighoffer wrote: And there are still some straggling bugs which cause this message to be erroneously printed. I'm pretty sure I've hit one of those :( Can't be certain though until I examine my specific case

Re: Fully-qualified symbol disambiguation is deprecated???

2016-09-08 Thread Nick Sabalausky via Digitalmars-d-learn
On 09/08/2016 06:13 PM, Steven Schveighoffer wrote: On 9/8/16 6:02 PM, Nick Sabalausky wrote: I'm getting deprecation messages ("Package...not accessible here, perhaps add static import") when simply trying to use fully-qualified symbol names to disambiguate a symbol. Is this reall

Fully-qualified symbol disambiguation is deprecated???

2016-09-08 Thread Nick Sabalausky via Digitalmars-d-learn
I'm getting deprecation messages ("Package...not accessible here, perhaps add static import") when simply trying to use fully-qualified symbol names to disambiguate a symbol. Is this really intended?

Get third part of front-end version number

2016-04-05 Thread Nick Sabalausky via Digitalmars-d-learn
These days, DMD/DMDFE version numbers are three parts, ex: 2.070.1. I can get the first two via std.compiler.version_major and std.compiler.version_minor. Is there a way to get the third part? I know I can "dmd --help | grep DMD", but that only works for DMD. GDC's "gdc --version" doesn't

Varargs and default arguments

2015-10-06 Thread Nick Sabalausky via Digitalmars-d-learn
Ok, D-style varargs can accept a parameter length of zero: --- void foo(T...)(T args) { //... } foo(); foo(t1, t2); --- Is there any way to stick a param with a default value before that? --- void foo(T...)(string str=null, T args=/+what goes here???+/)

const-correct structs, best practices?

2015-08-21 Thread Nick Sabalausky via Digitalmars-d-learn
Is there a good posting somewhere that summarizes the current best practices for making const-correct (ie works for all of mutable/const/immutable) structs?

Re: const-correct structs, best practices?

2015-08-21 Thread Nick Sabalausky via Digitalmars-d-learn
On 08/21/2015 12:22 PM, Dicebot wrote: On Friday, 21 August 2015 at 15:00:04 UTC, Nick Sabalausky wrote: Is there a good posting somewhere that summarizes the current best practices for making const-correct (ie works for all of mutable/const/immutable) structs? - mark methods const - avoid

Appender at CTFE?

2015-08-21 Thread Nick Sabalausky via Digitalmars-d-learn
Not at a pc, so can't test right now, but does Appender work at compile time? If not, does ~= still blow up CTFE memory usage like it used to? Any other best practice / trick for building strings in CTFE?

Re: Appender at CTFE?

2015-08-21 Thread Nick Sabalausky via Digitalmars-d-learn
Thanks! I wouldn't have expected that about the memory. But I wonder how much of that memory usage with Appender was just all the template instantiations. I'll have to look into that when I get back.

Bitfield-style enum to strings?

2015-05-07 Thread Nick Sabalausky via Digitalmars-d-learn
Assuming a plain old bitfield-style enum like: enum Foo { optionA = 10; optionB = 11; optionC = 12; optionD = 13; optionE = 14; } Does a function already exist somewhere to take an instance of Foo and get a list of the switch names as strings? Something kinda like: Foo

Re: Moving from Python to D

2015-05-07 Thread Nick Sabalausky via Digitalmars-d-learn
I'm not really sure exactly what parts are the issue, but I'll point out what I can: On 05/07/2015 11:24 PM, avarisclari wrote: Hello, Sorry to bother you with something trivial, but I am having trouble translating a block of code I wrote in Python over to D. Everything else I've figured out

Re: Moving from Python to D

2015-05-07 Thread Nick Sabalausky via Digitalmars-d-learn
On 05/08/2015 12:06 AM, Nick Sabalausky wrote: On 05/07/2015 11:24 PM, avarisclari wrote: scene = scenes[title] It looks like scenes is a dictionary that stores dictionaries of strings? If so, then in D, scenes would be declared like this: string[string][string] scenes; Then the above line

Re: Bitfield-style enum to strings?

2015-05-07 Thread Nick Sabalausky via Digitalmars-d-learn
On 05/07/2015 09:17 PM, Meta wrote: On Thursday, 7 May 2015 at 21:41:06 UTC, Nick Sabalausky wrote: On 05/07/2015 05:19 PM, Justin Whear wrote: T[] members = [ EnumMembers!T ]; Doh! Yup, that works. Still, I would think there should be a way to do it without allocating an array. But it's

Re: Bitfield-style enum to strings?

2015-05-07 Thread Nick Sabalausky via Digitalmars-d-learn
Gah, missed some imports that time: On 05/07/2015 05:04 PM, Nick Sabalausky wrote: Minor fix to work right for none fields. Already worked fine on combination fields liek all. - enum Foo { none = 0, optionA = 10, optionB = 11, optionC

Re: Bitfield-style enum to strings?

2015-05-07 Thread Nick Sabalausky via Digitalmars-d-learn
On 05/07/2015 01:41 PM, Nick Sabalausky wrote: Assuming a plain old bitfield-style enum like: enum Foo { optionA = 10; optionB = 11; optionC = 12; optionD = 13; optionE = 14; } Does a function already exist somewhere to take an instance of Foo and get a list

Re: Bitfield-style enum to strings?

2015-05-07 Thread Nick Sabalausky via Digitalmars-d-learn
On 05/07/2015 05:19 PM, Justin Whear wrote: On Thu, 07 May 2015 16:55:42 -0400, Nick Sabalausky wrote: // There's gotta be a better way to convert EnumMembers!T // to a range, right? But std.range.only() didn't work, // due to a template instantiation error. T[] members

Re: Bitfield-style enum to strings?

2015-05-07 Thread Nick Sabalausky via Digitalmars-d-learn
Minor fix to work right for none fields. Already worked fine on combination fields liek all. - enum Foo { none = 0, optionA = 10, optionB = 11, optionC = 12, optionD = 13, all = optionA | optionB | optionC | optionD, } import

line numbers in linux stack traces?

2014-10-05 Thread Nick Sabalausky via Digitalmars-d-learn
I know this keeps getting asked every year or so, but I couldn't find recent info. Are line numbers in linux stack traces supposed to be working at this point? Because I'm not getting any with 2.066.0 with either -g or -gc even when running under gdb. Kind of a pain, esp. compared to D dev on

Re: Installing LDC on Windows

2014-09-06 Thread Nick Sabalausky via Digitalmars-d-learn
On 9/6/2014 11:09 AM, Kagamin wrote: SEH was patented, so llvm doesn't support it. Seriously, if they're worried about infringing a software patent, they have no business writing any code at all. Avoiding things covered by patents *and* writing code that actually does anything useful is NOT

Good/Bad? @disable postblit for struct InputRange

2014-09-05 Thread Nick Sabalausky via Digitalmars-d-learn
One issue with struct-based input ranges: Saving the state of an input range is not supported (by definition of input range), and yet, you can trivially and accidentally do so with a simple assignment or passing into a function. The results may or may not blow up depending on the exact

Re: Good/Bad? @disable postblit for struct InputRange

2014-09-05 Thread Nick Sabalausky via Digitalmars-d-learn
On 9/5/2014 6:14 PM, monarch_dodra wrote: Ref semantics is one option, yes. Either by class, or by struct. For example, most IO ranges implemented ref-counted reference semantics. IMO, disabling postblit is overkill, as almost anything that does anything with ranges will pass them by value at

Re: Curl Exception

2014-05-11 Thread Nick Sabalausky via Digitalmars-d-learn
On 5/10/2014 9:02 AM, Jack wrote: First off a rant: I use the Code::Blocks IDE and at times it has been proven to a double-edged source because of various issueslike this one: http://forum.dlang.org/thread/ndeyzrifseipuebvy...@forum.dlang.org) and am now itching to search for other IDEs to

Re: Implicit static-dynamic arr and modifying

2014-05-07 Thread Nick Sabalausky via Digitalmars-d-learn
On 5/6/2014 6:46 PM, Rene Zwanenburg wrote: On Tuesday, 6 May 2014 at 02:17:06 UTC, Nick Sabalausky wrote: So all is well, and deliberately so. Pardon the noise. IMO it's not. I once had a particularly nasty bug because of this: struct S { @safe: string str; this(string data

Re: [Rosettacode] D code line length limit

2014-05-07 Thread Nick Sabalausky via Digitalmars-d-learn
On 5/7/2014 9:25 AM, bearophile wrote: So far in Rosettacode D entries I've kept a line length limit of 72 or 73 chars. But now a little larger monitors are common, D UFCS chains are common, and we also have longer function signatures with pure nothrow @safe @nogc (that usually I put on a new

Implicit static-dynamic arr and modifying

2014-05-05 Thread Nick Sabalausky via Digitalmars-d-learn
Is this kinds stuff a sane thing to do, or does it just work by accident?: void modify(ubyte[] dynamicArr) { dynamicArr[$-1] = 5; } void main() { ubyte[4] staticArr = [1,1,1,1]; modify(staticArr); assert(staticArr == [1,1,1,5]); }

Re: Implicit static-dynamic arr and modifying

2014-05-05 Thread Nick Sabalausky via Digitalmars-d-learn
On 5/5/2014 10:11 PM, Nick Sabalausky wrote: Is this kinds stuff a sane thing to do, or does it just work by accident?: void modify(ubyte[] dynamicArr) { dynamicArr[$-1] = 5; } void main() { ubyte[4] staticArr = [1,1,1,1]; modify(staticArr); assert(staticArr == [1,1,1,5

Extracting Params of Templated Type

2014-04-03 Thread Nick Sabalausky
If you have a templated type, is there a way to get the compile-time parameters it was instantiated with? Ie: -- struct Foo(T) {} alias MyFoo = Foo!int; -- Is there a way to inspect MyFoo to get its T type (in this case, 'int')? *Without* actually

Re: Extracting Params of Templated Type

2014-04-03 Thread Nick Sabalausky
On 4/4/2014 1:02 AM, Meta wrote: alias TemplateArgs(T: Foo!U, U) = U; void main() { assert(is(TemplateArgs!MyFoo == int)); } Ahh thanks.

Re: writeln if not empty

2014-03-10 Thread Nick Sabalausky
On 3/10/2014 9:24 PM, Timothee Cour wrote: Is there a way to do the following lazily: writelnIfNotEmpty(T)(T a){ auto b=text(a); if(b.length) writeln(b); } ie, without using std.conv.text (which needlessly computes an intermediate string, which could be quite large) or launching a separate

Re: Converting string to ascii value

2014-03-07 Thread Nick Sabalausky
On 3/7/2014 5:21 PM, Setra wrote: Hello all! I am having trouble converting a letter in a array of string to the ascii value. For example: First of all: string[] stringarray[3]; This isn't your main problem, but that line is incorrect. Actually, I'm kinda surprised that even works. It

Re: Converting string to ascii value

2014-03-07 Thread Nick Sabalausky
On 3/7/2014 5:33 PM, H. S. Teoh wrote: long x = cast(ubyte) stringarray[0]; long x = cast(ubyte) stringarray[0][0]; ;)

Re: Converting string to ascii value

2014-03-07 Thread Nick Sabalausky
On 3/7/2014 5:37 PM, Setra wrote: Thanks! Now I feel kind of dumb. For some reason I thought it would not be that simple... In a lot of languages it isn't that simple ;)

Re: Nobody understands templates?

2014-03-04 Thread Nick Sabalausky
On 3/1/2014 1:00 PM, Steve Teale wrote: I have already dealt with the yada-yada cases by old-fashioned OOP. As I see it, a big part of the benefit of templates is that they can help you avoid a lot of the downsides of OOP: - OO Boilerplate. - Multiple dispatch is ridiculously messy, having

Re: Nobody understands templates?

2014-03-04 Thread Nick Sabalausky
On 3/4/2014 7:42 PM, bearophile wrote: Nick Sabalausky: - Lumping all data/functionality for a single object instance into the same physical chunk of memory causes problems for parallelization. And that's increasingly problematic on modern processors which work best when operating as streaming

Re: Nobody understands templates?

2014-03-04 Thread Nick Sabalausky
On 3/3/2014 5:35 PM, Chris wrote: Maybe I'm a bit too philosophical about this. But consider the following (made up) case: struct MyTemp(T) { // ... T add(T a, T b) { if (a is string b is string) { return a~b; // or return a~+~b; or whatever } else

Re: Nobody understands templates?

2014-03-04 Thread Nick Sabalausky
On 3/4/2014 1:27 PM, H. S. Teoh wrote: On Tue, Mar 04, 2014 at 06:19:38PM +, Chris wrote: Btw, the quote you have in this post: Never ascribe to malice that which is adequately explained by incompetence. -- Napoleon Bonaparte I'm surprised that Napoleon would say something like this.

Re: Nobody understands templates?

2014-03-04 Thread Nick Sabalausky
On 3/4/2014 9:00 PM, bearophile wrote: Nick Sabalausky: But, I admit, I have wondered if a language could aid the creation/usage of entity systems with some special language features. I have seen that a good way to learn lazyness and purity is to try to write some Haskell code. Then you can

Re: Optimize my code =)

2014-02-17 Thread Nick Sabalausky
On 2/16/2014 6:47 PM, Robin wrote: @Nick Sabalausky: Don't be shocked at the bad performance of a beginner D programmer. At least I am not shocked yet that my D implementation isn't performing as well as the highly optimized C++11 implementation or the JIT-optimized Java implementation

Re: Optimize my code =)

2014-02-17 Thread Nick Sabalausky
On 2/17/2014 4:56 PM, Robin wrote: And here is the complete and improved code: http://dpaste.dzfl.pl/7f8610efa82b You should get rid of the .dup's in the constructors and postblits. You don't want big arrays ever getting accidentally allocated and copied behind your back when you're only

Re: Optimize my code =)

2014-02-14 Thread Nick Sabalausky
On 2/14/2014 11:00 AM, Robin wrote: class Matrix(T = double) { private T[] data; private Dimension dim; } A matrix is just plain-old-data, so use a struct, you don't need a class. A struct will be much more lightweight: A struct doesn't normally involve memory allocations like a

Re: Custom default exception handler?

2014-02-13 Thread Nick Sabalausky
On 2/12/2014 6:14 PM, Sean Kelly wrote: On Wednesday, 12 February 2014 at 22:42:45 UTC, Nick Sabalausky wrote: Tried on both 2.064.2 and 2.065-b3. Could it be that the custom toString just doesn't get run for static exceptions? It should. I'm not entirely sure why it isn't working

Re: Custom default exception handler?

2014-02-13 Thread Nick Sabalausky
On 2/13/2014 2:55 AM, Nick Sabalausky wrote: But if I use the RDMD/DMD *both* from DMD 2.065-b3 then...I dunno, either the exe doesn't get actually get rebuilt even with --force, or maybe it does but then runs an older copy of the exe, or something screwy like that. I need to look into that more

Re: Trouble Compiling DMD, Druntime, Phobos on Windows

2014-02-13 Thread Nick Sabalausky
On 2/13/2014 8:09 PM, Meta wrote: I'm using Windows 7 x64, but compiling 32-bit DMD. DMD compiles fine, but the linker warns about a Warning 9: Unknown Option : LA. After that, when trying to compile Druntime, DMD chokes with this error: Sounds like you're using an outdated OPTLINK. The /LA

Re: Multiple-OS Header Access

2014-02-12 Thread Nick Sabalausky
On 2/12/2014 12:21 PM, Malkierian wrote: Alright, so I'm making a little utility, and it looks like I'm going to need to access OS-specific header functions on each operating system in order to make it work, because 1) I want to get a list of all active processes and their names and 2) I want to

Custom default exception handler?

2014-02-11 Thread Nick Sabalausky
I don't suppose there's a way to change the default exception handler without using a modified druntime? I'm not seeing one in the docs, but I could have overlooked something. Replacing a druntime function at link-time wouldn't be ideal because then druntime's handler couldn't be called as a

Re: Custom default exception handler?

2014-02-11 Thread Nick Sabalausky
On 2/10/2014 10:57 PM, Adam D. Ruppe wrote: On Tuesday, 11 February 2014 at 03:53:05 UTC, Nick Sabalausky wrote: I don't suppose there's a way to change the default exception handler without using a modified druntime I'm pretty sure there used to be, but not anymore looking at the source

Re: Custom default exception handler?

2014-02-11 Thread Nick Sabalausky
On 2/11/2014 10:00 AM, Adam D. Ruppe wrote: So this would work too: int handleError(void delegate() dg) { try dg(); catch(Throwable t) return 1; return 0; } int main() { return handleError({ }); } Oh yea, good point. That's not bad at all;

Re: Custom default exception handler?

2014-02-11 Thread Nick Sabalausky
On 2/11/2014 6:35 PM, Sean Kelly wrote: Throw a static exception (maybe even derived directly from Throwable), similar to OutOfMemory, with a custom toString. That should eliminate the formatting you don't like and will prevent the trace from occurring as well (see rt/deh.d in Druntime--the

Re: Custom default exception handler?

2014-02-11 Thread Nick Sabalausky
On 2/11/2014 6:35 PM, Sean Kelly wrote: Throw a static exception (maybe even derived directly from Throwable), I assume then that throwing something directly derived from Throwable would still run cleanup code (like scope guards and finally) like throwing Exception would? Or is it like

Re: Custom default exception handler?

2014-02-11 Thread Nick Sabalausky
On 2/11/2014 6:35 PM, Sean Kelly wrote: Throw a static exception (maybe even derived directly from Throwable), similar to OutOfMemory, with a custom toString. That should eliminate the formatting you don't like and will prevent the trace from occurring as well (see rt/deh.d in Druntime--the

Overload sets and templates

2014-02-08 Thread Nick Sabalausky
This works: -- void foo(T)(T t) if(is(T==char)) {} void foo(T)(T t) if(is(T==int )) {} void main() { foo(1); } -- But if I move the int version to a different module, and try to alias it into the current module's overload set (like I can

Re: Overload sets and templates

2014-02-08 Thread Nick Sabalausky
On 2/8/2014 11:35 AM, Timon Gehr wrote: What you are trying to do should work. I.e. this is a compiler bug. Thanks. Filed: https://d.puremagic.com/issues/show_bug.cgi?id=12111

pure vs writeln debugging

2014-02-08 Thread Nick Sabalausky
Is there some way to poke enough of a hole in pure to get some writeln debugging statements in?

Re: pure vs writeln debugging

2014-02-08 Thread Nick Sabalausky
On 2/8/2014 5:30 PM, Adam D. Ruppe wrote: On Saturday, 8 February 2014 at 22:27:39 UTC, Nick Sabalausky wrote: Is there some way to poke enough of a hole in pure to get some writeln debugging statements in? literally write debug writeln(..) abnd it should work in the pure function Nice

  1   2   3   4   5   >