Re: Why tuples are not ranges?

2018-06-28 Thread Alex via Digitalmars-d-learn
On Thursday, 28 June 2018 at 19:02:51 UTC, Ali Çehreli wrote: On 06/28/2018 11:08 AM, Mr.Bingo wrote: > Thanks, why not add the ability to pass through ranges and arrays and > add it to phobos? Makes sense. It needs an enhancement request at http://issues.dlang.org/, a good implementation,

Re: errnoEnforce: which imports?

2018-06-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, June 29, 2018 01:25:39 kdevel via Digitalmars-d-learn wrote: > In https://dlang.org/phobos/std_exception.html#errnoEnforce this > example is shown: > > --- > auto f = errnoEnforce(fopen("data.txt")); > auto line = readln(f); > enforce(line.length); // expect a non-empty line > --- > > I

Re: Create D binding for C struct containing templated class

2018-06-28 Thread evilrat via Digitalmars-d-learn
On Thursday, 28 June 2018 at 18:43:11 UTC, Andre Pany wrote: Hi, I try to write a binding for the GRPC core. There is a struct which has some ugly fields: (https://github.com/grpc/grpc/blob/master/src/core/lib/surface/call.cc#L229) struct grpc_call { gpr_refcount ext_ref; gpr_arena*

errnoEnforce: which imports?

2018-06-28 Thread kdevel via Digitalmars-d-learn
In https://dlang.org/phobos/std_exception.html#errnoEnforce this example is shown: --- auto f = errnoEnforce(fopen("data.txt")); auto line = readln(f); enforce(line.length); // expect a non-empty line --- I added import std.stdio; import std.exception; and get an error message which

Re: Nullable!T with T of class type

2018-06-28 Thread Jordan Wilson via Digitalmars-d-learn
On Thursday, 28 June 2018 at 19:22:38 UTC, Jonathan M Davis wrote: On Thursday, June 28, 2018 18:10:07 kdevel via Digitalmars-d-learn wrote: On Tuesday, 26 June 2018 at 21:54:49 UTC, Jonathan M Davis wrote: > [H]onestly, I don't understand why folks keep trying to put > nullable types in

Re: Nullable!T with T of class type

2018-06-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, June 28, 2018 19:45:52 kdevel via Digitalmars-d-learn wrote: > On Thursday, 28 June 2018 at 19:22:38 UTC, Jonathan M Davis wrote: > > Nullable makes sense in generic code, because the code isn't > > written specifically for them, but something like > > Nullable!MyClass in non-generic

Re: Nullable!T with T of class type

2018-06-28 Thread aliak via Digitalmars-d-learn
On Thursday, 28 June 2018 at 18:10:07 UTC, kdevel wrote: On Tuesday, 26 June 2018 at 21:54:49 UTC, Jonathan M Davis wrote: [H]onestly, I don't understand why folks keep trying to put nullable types in Nullable in non-generic code. How do you signify that a struct member of class type is

Re: Nullable!T with T of class type

2018-06-28 Thread kdevel via Digitalmars-d-learn
On Thursday, 28 June 2018 at 19:22:38 UTC, Jonathan M Davis wrote: Nullable makes sense in generic code, because the code isn't written specifically for them, but something like Nullable!MyClass in non-generic code is pointless IMHO, because a class reference is already nullable. It is

Re: Nullable!T with T of class type

2018-06-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, June 28, 2018 18:10:07 kdevel via Digitalmars-d-learn wrote: > On Tuesday, 26 June 2018 at 21:54:49 UTC, Jonathan M Davis wrote: > > [H]onestly, I don't understand why folks keep trying to put > > nullable types in Nullable in non-generic code. > > How do you signify that a struct

Re: Why tuples are not ranges?

2018-06-28 Thread Ali Çehreli via Digitalmars-d-learn
On 06/28/2018 11:08 AM, Mr.Bingo wrote: > Thanks, why not add the ability to pass through ranges and arrays and > add it to phobos? Makes sense. It needs an enhancement request at http://issues.dlang.org/, a good implementation, and a pull request. :) Ali

Create D binding for C struct containing templated class

2018-06-28 Thread Andre Pany via Digitalmars-d-learn
Hi, I try to write a binding for the GRPC core. There is a struct which has some ugly fields: (https://github.com/grpc/grpc/blob/master/src/core/lib/surface/call.cc#L229) struct grpc_call { gpr_refcount ext_ref; gpr_arena* arena; ... grpc_core::ManualConstructor sending_stream;

Re: Nullable!T with T of class type

2018-06-28 Thread kdevel via Digitalmars-d-learn
On Tuesday, 26 June 2018 at 21:54:49 UTC, Jonathan M Davis wrote: [H]onestly, I don't understand why folks keep trying to put nullable types in Nullable in non-generic code. How do you signify that a struct member of class type is optional?

Re: Why tuples are not ranges?

2018-06-28 Thread Meta via Digitalmars-d-learn
On Thursday, 28 June 2018 at 17:00:37 UTC, Mr.Bingo wrote: I mean, if you think about it, the memory layout of a tuple is sequential types: T1 T2 ... So, to popFront a tuple is just changing the starting offset. You're right; it can definitely be done. struct TupleRange(T...) {

Re: Why tuples are not ranges?

2018-06-28 Thread Mr.Bingo via Digitalmars-d-learn
On Thursday, 28 June 2018 at 18:03:09 UTC, Ali Çehreli wrote: On 06/28/2018 10:00 AM, Mr.Bingo wrote: > But is this going to be optimized? Not our job! :o) > That is, a tuple is a range! Similar to the array-slice distinction, tuple is a container, needing its range. > It is clearly easy

Re: Why tuples are not ranges?

2018-06-28 Thread Ali Çehreli via Digitalmars-d-learn
On 06/28/2018 10:00 AM, Mr.Bingo wrote: > But is this going to be optimized? Not our job! :o) > That is, a tuple is a range! Similar to the array-slice distinction, tuple is a container, needing its range. > It is clearly easy to see if a tuple is empty, to get the front, Ok. > and to >

Re: Why tuples are not ranges?

2018-06-28 Thread Mr.Bingo via Digitalmars-d-learn
On Thursday, 28 June 2018 at 16:02:59 UTC, Alex wrote: On Thursday, 28 June 2018 at 14:35:33 UTC, Mr.Bingo wrote: Seems like it would unify things quite a bit. Yeah... this is, because you can't popFront on a tuple, as the amount of entries is fixed. You can, however, popFront on every

Re: Why tuples are not ranges?

2018-06-28 Thread Alex via Digitalmars-d-learn
On Thursday, 28 June 2018 at 14:35:33 UTC, Mr.Bingo wrote: Seems like it would unify things quite a bit. Yeah... this is, because you can't popFront on a tuple, as the amount of entries is fixed. You can, however, popFront on every range. But as Timoses wrote you can easily make a range

Re: Why tuples are not ranges?

2018-06-28 Thread Timoses via Digitalmars-d-learn
On Thursday, 28 June 2018 at 14:35:33 UTC, Mr.Bingo wrote: Seems like it would unify things quite a bit. import std.typecons, std.range, std.array, std.algorithm, std.stdio; void main() { auto t = tuple(3,4,5,6); //auto t = [3,4,5,6]; writeln(t.map!(a =>

Re: E-mail attachment with scrambled text.

2018-06-28 Thread vino.B via Digitalmars-d-learn
On Thursday, 28 June 2018 at 12:36:11 UTC, Simen Kjærås wrote: On Thursday, 28 June 2018 at 11:46:31 UTC, vino.B wrote: Output in Linux Server Details** Server Name : 1 IP: 1XX Server Name : 2 IP: 2XX Server Name : 3 IP: 3XX

Re: Getting Source code from complied code.

2018-06-28 Thread Timoses via Digitalmars-d-learn
On Thursday, 28 June 2018 at 08:01:42 UTC, vino.B wrote: Hi All, Request your help on how to get the source code, i wrote a program named clean.d, complied it and by mistake deleted the source code(clean.d), so can we get back the source using the complied program(clean), if yes, can you

Why tuples are not ranges?

2018-06-28 Thread Mr.Bingo via Digitalmars-d-learn
Seems like it would unify things quite a bit. import std.typecons, std.range, std.array, std.algorithm, std.stdio; void main() { auto t = tuple(3,4,5,6); //auto t = [3,4,5,6]; writeln(t.map!(a => 3*a).sum()); }

Re: Getting Source code from complied code.

2018-06-28 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/28/18 4:33 AM, vino.B wrote: Hi Basile,  Thank you very much, luckily the file was backed up by the backup scheduler, so was able to restore the same. I was going to suggest, next time use a backup, but you already have. Amazing how nice it is when you realize that has happened :)

Re: -dip1000 @safe scope wrapper

2018-06-28 Thread Chris M. via Digitalmars-d-learn
On Thursday, 28 June 2018 at 13:29:58 UTC, vit wrote: Hello, Is it possible to create scope wrapper initialized by non default constructor with scope parameter? something like this: struct Wrapper{ int* p; static Wrapper create(scope return int* p)@safe{ Wrapper w;

-dip1000 @safe scope wrapper

2018-06-28 Thread vit via Digitalmars-d-learn
Hello, Is it possible to create scope wrapper initialized by non default constructor with scope parameter? something like this: struct Wrapper{ int* p; static Wrapper create(scope return int* p)@safe{ Wrapper w; w.p = p; return w; } /++ This doesn't

Re: E-mail attachment with scrambled text.

2018-06-28 Thread Simen Kjærås via Digitalmars-d-learn
On Thursday, 28 June 2018 at 11:46:31 UTC, vino.B wrote: Output in Linux Server Details** Server Name : 1 IP: 1XX Server Name : 2 IP: 2XX Server Name : 3 IP: 3XX The output in

E-mail attachment with scrambled text.

2018-06-28 Thread vino.B via Digitalmars-d-learn
Hi All, Request your help, i have a D code which generates a log file with below text, in Linux, when i send this log file(text file) as an mail attachment the text in the attachment are scrambled so request your help on this. Tried the below Options (no luck): Content-Type: text/plain

Re: turn range into tuple ?

2018-06-28 Thread Flaze07 via Digitalmars-d-learn
On Thursday, 28 June 2018 at 09:47:07 UTC, Jonathan M Davis wrote: On Thursday, June 28, 2018 09:26:10 Flaze07 via Digitalmars-d-learn wrote: On Thursday, 28 June 2018 at 08:52:33 UTC, Simen Kjærås wrote: > [...] what about during runtime ? Ranges in general have an arbitrary length,

Re: turn range into tuple ?

2018-06-28 Thread Flaze07 via Digitalmars-d-learn
On Thursday, 28 June 2018 at 09:42:54 UTC, Flaze07 wrote: On Thursday, 28 June 2018 at 09:38:36 UTC, Stefan Koch wrote: On Thursday, 28 June 2018 at 09:26:10 UTC, Flaze07 wrote: On Thursday, 28 June 2018 at 08:52:33 UTC, Simen Kjærås wrote: On Thursday, 28 June 2018 at 08:36:54 UTC, Flaze07

Re: turn range into tuple ?

2018-06-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, June 28, 2018 09:26:10 Flaze07 via Digitalmars-d-learn wrote: > On Thursday, 28 June 2018 at 08:52:33 UTC, Simen Kjærås wrote: > > On Thursday, 28 June 2018 at 08:36:54 UTC, Flaze07 wrote: > >> is there some sort of ways to turn range into tuple ? ( an > >> array preferably ) > >> e.g

Re: turn range into tuple ?

2018-06-28 Thread Flaze07 via Digitalmars-d-learn
On Thursday, 28 June 2018 at 09:38:36 UTC, Stefan Koch wrote: On Thursday, 28 June 2018 at 09:26:10 UTC, Flaze07 wrote: On Thursday, 28 June 2018 at 08:52:33 UTC, Simen Kjærås wrote: On Thursday, 28 June 2018 at 08:36:54 UTC, Flaze07 wrote: is there some sort of ways to turn range into tuple ?

Re: turn range into tuple ?

2018-06-28 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 28 June 2018 at 09:26:10 UTC, Flaze07 wrote: On Thursday, 28 June 2018 at 08:52:33 UTC, Simen Kjærås wrote: On Thursday, 28 June 2018 at 08:36:54 UTC, Flaze07 wrote: is there some sort of ways to turn range into tuple ? ( an array preferably ) e.g uint[] arr = [ 10, 20, 30 ];

Re: turn range into tuple ?

2018-06-28 Thread Flaze07 via Digitalmars-d-learn
On Thursday, 28 June 2018 at 08:52:33 UTC, Simen Kjærås wrote: On Thursday, 28 June 2018 at 08:36:54 UTC, Flaze07 wrote: is there some sort of ways to turn range into tuple ? ( an array preferably ) e.g uint[] arr = [ 10, 20, 30 ]; auto tup = rangeToTup( arr ); assert( tup[ 0 ] == 10 );

Re: turn range into tuple ?

2018-06-28 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 28 June 2018 at 08:36:54 UTC, Flaze07 wrote: is there some sort of ways to turn range into tuple ? ( an array preferably ) e.g uint[] arr = [ 10, 20, 30 ]; auto tup = rangeToTup( arr ); assert( tup[ 0 ] == 10 ); assert( tup[ 1 ] == 20 ); assert( tup[ 2 ] == 30 ); I think you are

Re: turn range into tuple ?

2018-06-28 Thread Simen Kjærås via Digitalmars-d-learn
On Thursday, 28 June 2018 at 08:36:54 UTC, Flaze07 wrote: is there some sort of ways to turn range into tuple ? ( an array preferably ) e.g uint[] arr = [ 10, 20, 30 ]; auto tup = rangeToTup( arr ); assert( tup[ 0 ] == 10 ); assert( tup[ 1 ] == 20 ); assert( tup[ 2 ] == 30 );

turn range into tuple ?

2018-06-28 Thread Flaze07 via Digitalmars-d-learn
is there some sort of ways to turn range into tuple ? ( an array preferably ) e.g uint[] arr = [ 10, 20, 30 ]; auto tup = rangeToTup( arr ); assert( tup[ 0 ] == 10 ); assert( tup[ 1 ] == 20 ); assert( tup[ 2 ] == 30 );

Re: Getting Source code from complied code.

2018-06-28 Thread vino.B via Digitalmars-d-learn
On Thursday, 28 June 2018 at 08:21:20 UTC, Basile B. wrote: On Thursday, 28 June 2018 at 08:01:42 UTC, vino.B wrote: Hi All, Request your help on how to get the source code, i wrote a program named clean.d, complied it and by mistake deleted the source code(clean.d), so can we get back the

Re: Getting Source code from complied code.

2018-06-28 Thread Basile B. via Digitalmars-d-learn
On Thursday, 28 June 2018 at 08:01:42 UTC, vino.B wrote: Hi All, Request your help on how to get the source code, i wrote a program named clean.d, complied it and by mistake deleted the source code(clean.d), so can we get back the source using the complied program(clean), if yes, can you

Getting Source code from complied code.

2018-06-28 Thread vino.B via Digitalmars-d-learn
Hi All, Request your help on how to get the source code, i wrote a program named clean.d, complied it and by mistake deleted the source code(clean.d), so can we get back the source using the complied program(clean), if yes, can you any one help on the same. From, Vino.B