Re: Passing struct to function

2018-06-13 Thread Michał via Digitalmars-d-learn
On Wednesday, 13 June 2018 at 17:37:44 UTC, Steven Schveighoffer wrote: Hm... the only way to do it in D is to provide a function that checks whether the small vector optimization is in play, and return a pointer/slice to itself. With D it is possible to alias the getter function that

Re: Docs for subpackages?

2018-06-13 Thread 9il via Digitalmars-d-learn
On Wednesday, 13 June 2018 at 14:56:10 UTC, 9il wrote: Hi, I am trying to build a large project that is split into dozen of sub-packages. How I can do it using dub without writing my own doc scripts? --combined does not help here. Best regards, Ilya UPDATE: --combined works, but DDOX fails

InputRange help: (1) repeated dtor calls and (2) managing resources needing free()

2018-06-13 Thread James Blachly via Digitalmars-d-learn
Hi all, I now really appreciate the power Ranges provide and am an avid consumer, but am only slowly becoming accustomed to implementing my own. In the present problem, I am writing a binding to a C library (htslib) that provides many functions related to high-throughput sequencing files.

Re: Which character set does D use?

2018-06-13 Thread Uknown via Digitalmars-d-learn
On Wednesday, 13 June 2018 at 23:34:02 UTC, Murilo wrote: Does D use ASCII or UNICODE? It seems to use ASCII since it causes error whenever I use a non-ASCII character. Your system might be misconfigured. D can use UTF-8 (Unicode) too. See https://dlang.org/spec/lex.html#source_text

Which character set does D use?

2018-06-13 Thread Murilo via Digitalmars-d-learn
Does D use ASCII or UNICODE? It seems to use ASCII since it causes error whenever I use a non-ASCII character.

Re: Class qualifier vs struct qualifier

2018-06-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, June 13, 2018 14:33:48 Jonathan M Davis via Digitalmars-d- learn wrote: > On Wednesday, June 13, 2018 07:35:25 RazvanN via Digitalmars-d-learn wrote: > > Hello, > > > > I'm having a hard time understanding whether this inconsistency > > is a bug or intended behavior: > > > >

Re: Class qualifier vs struct qualifier

2018-06-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, June 13, 2018 07:35:25 RazvanN via Digitalmars-d-learn wrote: > Hello, > > I'm having a hard time understanding whether this inconsistency > is a bug or intended behavior: > > immutable class Foo {} > immutable struct Bar {} > > void main() > { > import std.stdio : writeln; >

Re: Runtime introspection, or how to get class members at runtime Fin D

2018-06-13 Thread concepthf via Digitalmars-d-learn
On Friday, 8 June 2018 at 08:21:39 UTC, evilrat wrote: On Friday, 8 June 2018 at 08:06:27 UTC, Arafel wrote: On Thursday, 7 June 2018 at 13:07:21 UTC, evilrat wrote: I don't think so. It clearly states that children must mixin too, which can mean it just grabs symbols in scope only, and

Re: What is the point of nothrow?

2018-06-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, June 13, 2018 10:56:41 wjoe via Digitalmars-d-learn wrote: > On Wednesday, 13 June 2018 at 03:14:33 UTC, Jonathan M Davis > > wrote: > > Most programs do not handle the case where they run out of > > memory and cannot continue at that point. For better or worse, > > D's GC was

Re: Passing struct to function

2018-06-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/13/18 1:08 PM, Michał wrote: On Wednesday, 13 June 2018 at 16:40:51 UTC, Steven Schveighoffer wrote: On 6/13/18 10:43 AM, Michał wrote: When I pass my struct to function something is going wrong. I don't know how to fix it. Code: import std.stdio; void print(ref Vector v, string s){   

Re: Passing struct to function

2018-06-13 Thread Michał via Digitalmars-d-learn
On Wednesday, 13 June 2018 at 16:40:51 UTC, Steven Schveighoffer wrote: On 6/13/18 10:43 AM, Michał wrote: When I pass my struct to function something is going wrong. I don't know how to fix it. Code: import std.stdio; void print(ref Vector v, string s){     writefln("%s==%s    %s", ,

Re: What is the point of nothrow?

2018-06-13 Thread wjoe via Digitalmars-d-learn
On Wednesday, 13 June 2018 at 13:05:44 UTC, Kagamin wrote: On Wednesday, 13 June 2018 at 10:56:41 UTC, wjoe wrote: I understand the idea that an Error is not supposed to be caught but why would such a 'feature' be desirable? Where's the benefit if nothing can be relied upon ? It's a

Re: What is the point of nothrow?

2018-06-13 Thread wjoe via Digitalmars-d-learn
On Wednesday, 13 June 2018 at 12:59:27 UTC, Kagamin wrote: On Wednesday, 13 June 2018 at 02:02:54 UTC, wjoe wrote: it is possible to install a signal handler for almost every signal on POSIX, including segfault. The only signal you can't catch is signal 9 - sigkill if memory serves. So I could

Re: Passing struct to function

2018-06-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/13/18 10:43 AM, Michał wrote: When I pass my struct to function something is going wrong. I don't know how to fix it. Code: import std.stdio; void print(ref Vector v, string s){     writefln("%s==%s    %s", , v.ptr, s); } struct Vector { int x; int* ptr; this(this)

Re: What is the point of nothrow?

2018-06-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/13/18 8:44 AM, Kagamin wrote: On Tuesday, 12 June 2018 at 14:15:42 UTC, Steven Schveighoffer wrote: I predict at some point when Errors actually don't do proper cleanup, it is going to be a really difficult time for D. Looks like it already doesn't: https://run.dlang.io/is/OhDwtW Damn,

Re: implicit or module-wide @nogc

2018-06-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/13/18 3:24 AM, Mike Franklin wrote: Because D is more evolution then intelligent design, unfortunately. I had to LOL on this, nice :) -Steve

Re: Class qualifier vs struct qualifier

2018-06-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/13/18 3:35 AM, RazvanN wrote: Hello, I'm having a hard time understanding whether this inconsistency is a bug or intended behavior: immutable class Foo {} immutable struct Bar {} void main() {     import std.stdio : writeln;     Foo a;     Bar b;     writeln("typeof(a): ",

Re: remove not callable for char[]

2018-06-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/13/18 1:18 AM, Flaze07 wrote: I see, so it means that only char is affected, gotcha Well, char[] and wchar[]. dchar[] is treated as an array by Phobos. But calling byCodeUnit on a dchar array should work just like an array as well, so using it is the most generic solution. -Steve

Docs for subpackages?

2018-06-13 Thread 9il via Digitalmars-d-learn
Hi, I am trying to build a large project that is split into dozen of sub-packages. How I can do it using dub without writing my own doc scripts? --combined does not help here. Best regards, Ilya

Passing struct to function

2018-06-13 Thread Michał via Digitalmars-d-learn
When I pass my struct to function something is going wrong. I don't know how to fix it. Code: import std.stdio; void print(ref Vector v, string s){ writefln("%s==%s%s", , v.ptr, s); } struct Vector { int x; int* ptr; this(this) {

Re: What is the point of nothrow?

2018-06-13 Thread Kagamin via Digitalmars-d-learn
On Wednesday, 13 June 2018 at 10:56:41 UTC, wjoe wrote: I understand the idea that an Error is not supposed to be caught but why would such a 'feature' be desirable? Where's the benefit if nothing can be relied upon ? It's a debugging facility for development stage that allows to print the

Re: What is the point of nothrow?

2018-06-13 Thread Kagamin via Digitalmars-d-learn
On Wednesday, 13 June 2018 at 02:02:54 UTC, wjoe wrote: it is possible to install a signal handler for almost every signal on POSIX, including segfault. The only signal you can't catch is signal 9 - sigkill if memory serves. So I could for instance install a clean up handler on a segfault via

Re: What is the point of nothrow?

2018-06-13 Thread Kagamin via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 14:15:42 UTC, Steven Schveighoffer wrote: I predict at some point when Errors actually don't do proper cleanup, it is going to be a really difficult time for D. Looks like it already doesn't: https://run.dlang.io/is/OhDwtW

Re: Pass arguments at compile time

2018-06-13 Thread bauss via Digitalmars-d-learn
On Wednesday, 13 June 2018 at 10:57:27 UTC, Malte wrote: I want to import a config file at compile time, but also need a way to have multiple configurations. With gcc you could do something like -DIMPORTFROM='"MyConfigFile.txt"'. Is there any equivalent in D? Hardcoding the config files for

Pass arguments at compile time

2018-06-13 Thread Malte via Digitalmars-d-learn
I want to import a config file at compile time, but also need a way to have multiple configurations. With gcc you could do something like -DIMPORTFROM='"MyConfigFile.txt"'. Is there any equivalent in D? Hardcoding the config files for different versions and using that is not an option.

Re: What is the point of nothrow?

2018-06-13 Thread wjoe via Digitalmars-d-learn
On Wednesday, 13 June 2018 at 03:14:33 UTC, Jonathan M Davis wrote: Most programs do not handle the case where they run out of memory and cannot continue at that point. For better or worse, D's GC was designed with that in mind, and it treats failed allocations as an Error. In the vast

Class qualifier vs struct qualifier

2018-06-13 Thread RazvanN via Digitalmars-d-learn
Hello, I'm having a hard time understanding whether this inconsistency is a bug or intended behavior: immutable class Foo {} immutable struct Bar {} void main() { import std.stdio : writeln; Foo a; Bar b; writeln("typeof(a): ", typeof(a).stringof); writeln("typeof(b): ",

Re: implicit or module-wide @nogc

2018-06-13 Thread Mike Franklin via Digitalmars-d-learn
On Wednesday, 13 June 2018 at 07:19:24 UTC, Gokhhy wrote: Nevermind, it doesn't affect functions inside classes and structs. Yeah, that's kindof unfortunate isn't it. Just do the same thing within the class/struct scope. class C { @nogc: void nogcMethod1() {} void nogcMehtod2()

Re: implicit or module-wide @nogc

2018-06-13 Thread Gokhhy via Digitalmars-d-learn
On Wednesday, 13 June 2018 at 07:14:35 UTC, Gokhhy wrote: On Wednesday, 13 June 2018 at 07:11:56 UTC, Mike Franklin wrote: On Wednesday, 13 June 2018 at 06:45:27 UTC, Gokhhy wrote: Is there a way to define an entire module as @nogc or otherwise make it so I don't have to qualify every single

Re: implicit or module-wide @nogc

2018-06-13 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 13 June 2018 at 06:45:27 UTC, Gokhhy wrote: Is there a way to define an entire module as @nogc or otherwise make it so I don't have to qualify every single function as @nogc? --- module module_wide-nogc; @nogc: /* declarations or statements... */ --- But this is not

Re: implicit or module-wide @nogc

2018-06-13 Thread Mike Franklin via Digitalmars-d-learn
On Wednesday, 13 June 2018 at 06:45:27 UTC, Gokhhy wrote: Is there a way to define an entire module as @nogc or otherwise make it so I don't have to qualify every single function as @nogc? You can put attributes at the top of a module followed by a ":" to have them apply to everything below

Re: implicit or module-wide @nogc

2018-06-13 Thread Gokhhy via Digitalmars-d-learn
On Wednesday, 13 June 2018 at 07:11:56 UTC, Mike Franklin wrote: On Wednesday, 13 June 2018 at 06:45:27 UTC, Gokhhy wrote: Is there a way to define an entire module as @nogc or otherwise make it so I don't have to qualify every single function as @nogc? You can put attributes at the top of a

implicit or module-wide @nogc

2018-06-13 Thread Gokhhy via Digitalmars-d-learn
Is there a way to define an entire module as @nogc or otherwise make it so I don't have to qualify every single function as @nogc?