Re: D doesn't read the first character of a file (reads everything but the first chararacter) with either read() or readText()

2017-07-18 Thread Sebastien Alaiwan via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 02:21:59 UTC, Enjoys Math wrote: DMD32 D Compiler v2.074.1 import std.file; void main() { string bigInput = readText("input.txt"); } The file is 7 MB of ascii text, don't know if that matters... Should I upgrade versions? Could you please share the first

Re: Is it possible to generate a pool of random D or D inline assembler programs, run them safely?

2017-07-18 Thread Sebastien Alaiwan via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 17:35:17 UTC, Enjoys Math wrote: Without them crashing the app running them? Say by wrapping with try / catch? and, most probably a timeout, as you're certainly going to run into infinite loops. Reason is so I don't have to make my own VM. Why not reuse an

Re: Is it possible to generate a pool of random D or D inline assembler programs, run them safely?

2017-07-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 17:35:17 UTC, Enjoys Math wrote: Without them crashing the app running them? Say by wrapping with try / catch? Run them in a separate process, so it can die independently.

Re: Appending static arrays

2017-07-18 Thread Jack Applegame via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 12:39:01 UTC, Stefan Koch wrote: whhhahhh template bloat Yes, and also very slow. :)

Re: Adding flags to dub build

2017-07-18 Thread Moritz Maxeiner via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 20:12:13 UTC, Jean-Louis Leroy wrote: On Tuesday, 18 July 2017 at 20:00:48 UTC, Guillaume Piolat wrote: On Tuesday, 18 July 2017 at 19:49:35 UTC, Jean-Louis Leroy wrote: Hi, I want to add a few flags while building with dub. I tried:

Re: Adding flags to dub build

2017-07-18 Thread Jean-Louis Leroy via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 20:12:13 UTC, Jean-Louis Leroy wrote: On Tuesday, 18 July 2017 at 20:00:48 UTC, Guillaume Piolat wrote: On Tuesday, 18 July 2017 at 19:49:35 UTC, Jean-Louis Leroy wrote: Hi, I want to add a few flags while building with dub. I tried:

Re: Adding flags to dub build

2017-07-18 Thread Jean-Louis Leroy via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 20:00:48 UTC, Guillaume Piolat wrote: On Tuesday, 18 July 2017 at 19:49:35 UTC, Jean-Louis Leroy wrote: Hi, I want to add a few flags while building with dub. I tried: DFLAGS='-d-version=explain' dub test ... ...but DFLAGS does not seem to be honored. In fact

Re: Adding flags to dub build

2017-07-18 Thread Guillaume Piolat via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 19:49:35 UTC, Jean-Louis Leroy wrote: Hi, I want to add a few flags while building with dub. I tried: DFLAGS='-d-version=explain' dub test ... ...but DFLAGS does not seem to be honored. In fact I wouldn't mind adding a builtType to my dub.sdl (but then will it

Adding flags to dub build

2017-07-18 Thread Jean-Louis Leroy via Digitalmars-d-learn
Hi, I want to add a few flags while building with dub. I tried: DFLAGS='-d-version=explain' dub test ... ...but DFLAGS does not seem to be honored. In fact I wouldn't mind adding a builtType to my dub.sdl (but then will it be inherited by the subpackages) but I don't see how to specify

Is it possible to generate a pool of random D or D inline assembler programs, run them safely?

2017-07-18 Thread Enjoys Math via Digitalmars-d-learn
Without them crashing the app running them? Say by wrapping with try / catch? You can assume that I've limited the opcode addresses to the program and/or the data section which I'll try to put right next to the code. Reason is so I don't have to make my own VM. I want to mutate computable

Re: How do I cast to from byte[] <-> double for making a small assembler language VM to work?

2017-07-18 Thread Enjoys Math via Digitalmars-d-learn
Thanks for the replies. I will look at 3-address opcodes and consider unions. *Wonders if it matters that Program is a struct with opSlice / opSliceAssign overloaded*.

Re: Can't get expected strings

2017-07-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, July 18, 2017 13:49:11 helxi via Digitalmars-d-learn wrote: > import std.stdio, std.datetime, std.conv, std.algorithm; > > void main() > { > immutable DEADLINE = DateTime(2017, 7, 16, 23, 59, > 59).to!SysTime; > immutable NOW = Clock.currTime; > immutable INTERVAL =

Re: replacement for squeeze and removechars.

2017-07-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, July 18, 2017 15:55:00 Seb via Digitalmars-d-learn wrote: > On Tuesday, 18 July 2017 at 15:41:44 UTC, Meta wrote: > > As Seb somewhat undiplomatically put, there are replacements > > listed in the changelog. > > Sorry - it wasn't intended to be an offense or aggressive. I >

Re: How do I cast to from byte[] <-> double for making a small assembler language VM to work?

2017-07-18 Thread H. S. Teoh via Digitalmars-d-learn
Maybe use a union? union U { double d; byte[double.sizeof] bytes; } U u; u.bytes = ...; double d = u.d; ... // do something with d // or: U u; u.d = 3.14159; byte[] b = u.bytes[];

Re: replacement for squeeze and removechars.

2017-07-18 Thread Antonio Corbi via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 15:55:00 UTC, Seb wrote: On Tuesday, 18 July 2017 at 15:41:44 UTC, Meta wrote: As Seb somewhat undiplomatically put, there are replacements listed in the changelog. Sorry - it wasn't intended to be an offense or aggressive. I consider(ed) RTFM as common internet

Re: replacement for squeeze and removechars.

2017-07-18 Thread Seb via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 15:41:44 UTC, Meta wrote: As Seb somewhat undiplomatically put, there are replacements listed in the changelog. Sorry - it wasn't intended to be an offense or aggressive. I consider(ed) RTFM as common internet slang.

Re: replacement for squeeze and removechars.

2017-07-18 Thread Antonio Corbi via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 15:41:44 UTC, Meta wrote: On Tuesday, 18 July 2017 at 15:28:06 UTC, Antonio Corbi wrote: Hi all, I'm trying dmd-2.075.0-rc1 in one of my projects where I use `squeeze` and `removechars`. Both of them are flagged as obsolete and in the docs we are suggested to use

Re: replacement for squeeze and removechars.

2017-07-18 Thread Meta via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 15:28:06 UTC, Antonio Corbi wrote: Hi all, I'm trying dmd-2.075.0-rc1 in one of my projects where I use `squeeze` and `removechars`. Both of them are flagged as obsolete and in the docs we are suggested to use functions from std.regex and/or std.algorithm. Does

Re: replacement for squeeze and removechars.

2017-07-18 Thread Seb via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 15:28:06 UTC, Antonio Corbi wrote: Hi all, I'm trying dmd-2.075.0-rc1 in one of my projects where I use `squeeze` and `removechars`. Both of them are flagged as obsolete and in the docs we are suggested to use functions from std.regex and/or std.algorithm. Does

replacement for squeeze and removechars.

2017-07-18 Thread Antonio Corbi via Digitalmars-d-learn
Hi all, I'm trying dmd-2.075.0-rc1 in one of my projects where I use `squeeze` and `removechars`. Both of them are flagged as obsolete and in the docs we are suggested to use functions from std.regex and/or std.algorithm. Does any one kow a one-liner from std.regex or std.algorithm that

Re: Idiomatic way of writing nested loops?

2017-07-18 Thread Russel Winder via Digitalmars-d-learn
On Tue, 2017-07-18 at 08:41 +, Anton Fediushin via Digitalmars-d-learn wrote: > On Tuesday, 18 July 2017 at 03:36:04 UTC, Nicholas Wilson wrote: > > With regards to parallel, only use it on the outermost loop. > > Assuming you have more items in the outermost loop than you do > > threads

Re: Idiomatic way of writing nested loops?

2017-07-18 Thread Russel Winder via Digitalmars-d-learn
On Tue, 2017-07-18 at 03:36 +, Nicholas Wilson via Digitalmars-d-learn wrote: > On Monday, 17 July 2017 at 11:07:35 UTC, Anton Fediushin wrote: > > […] > > > > Also, I have a question about running this in parallel: if I > > want to use nested loops with `parallel` from > >

Re: Get complete function declaration

2017-07-18 Thread SrMordred via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 13:53:11 UTC, Ivan Kazmenko wrote: On Tuesday, 18 July 2017 at 13:35:49 UTC, SrMordred wrote: There is a way to get the full function(or any other structure) declaration with traits? Or I will have to mount it with std.traits functions? eg. void add(int x, int

Re: Get complete function declaration

2017-07-18 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 13:35:49 UTC, SrMordred wrote: There is a way to get the full function(or any other structure) declaration with traits? Or I will have to mount it with std.traits functions? eg. void add(int x, int y){} GetFullFunctionDeclaration!add; //return "void add(int x, int

Can't get expected strings

2017-07-18 Thread helxi via Digitalmars-d-learn
import std.stdio, std.datetime, std.conv, std.algorithm; void main() { immutable DEADLINE = DateTime(2017, 7, 16, 23, 59, 59).to!SysTime; immutable NOW = Clock.currTime; immutable INTERVAL = (DEADLINE - NOW) .abs .to!string;

Get complete function declaration

2017-07-18 Thread SrMordred via Digitalmars-d-learn
There is a way to get the full function(or any other structure) declaration with traits? Or I will have to mount it with std.traits functions? eg. void add(int x, int y){} GetFullFunctionDeclaration!add; //return "void add(int x, int y)"

Re: Appending static arrays

2017-07-18 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 08:46:50 UTC, Jack Applegame wrote: On Monday, 17 July 2017 at 17:38:23 UTC, Nordlöw wrote: I'm want to define a specialization of `append()` that takes only static arrays as inputs and returns a static array being the sum of the lengths of the inputs. Have

Re: Appending static arrays

2017-07-18 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 08:07:45 UTC, Jacob Carlborg wrote: append - add array or element to existing array concat (concatenate) - add to arrays (or element) together to create a new array Seems like this is a concatenation. But please avoid shortening the names. I vote you go with

Re: How do I cast to from byte[] <-> double for making a small assembler language VM to work?

2017-07-18 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 11:06:22 UTC, Enjoys Math wrote: [ ... ] The cast at the bottom gives a compiler error (can't cast byte[] to double). If you want to see how it's done check: https://github.com/UplinkCoder/dmd/blob/newCTFE_on_master/src/ddmd/ctfe/bc.d Though if you have the choice

Re: How do I cast to from byte[] <-> double for making a small assembler language VM to work?

2017-07-18 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 11:06:22 UTC, Enjoys Math wrote: class OpCode { private: byte[] bytes_; public: void opCall(Program program) const; byte[] bytes() const { return bytes_.dup; } } class AddD : OpCode { private: uint d, s;

How do I cast to from byte[] <-> double for making a small assembler language VM to work?

2017-07-18 Thread Enjoys Math via Digitalmars-d-learn
class OpCode { private: byte[] bytes_; public: void opCall(Program program) const; byte[] bytes() const { return bytes_.dup; } } class AddD : OpCode { private: uint d, s; public: this(uint dst, uint src) { d =

Re: Appending static arrays

2017-07-18 Thread Jack Applegame via Digitalmars-d-learn
On Monday, 17 July 2017 at 17:38:23 UTC, Nordlöw wrote: I'm want to define a specialization of `append()` that takes only static arrays as inputs and returns a static array being the sum of the lengths of the inputs. Have anybody already implemented this? If not, I'm specifically interested

Re: Idiomatic way of writing nested loops?

2017-07-18 Thread Anton Fediushin via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 03:36:04 UTC, Nicholas Wilson wrote: With regards to parallel, only use it on the outermost loop. Assuming you have more items in the outermost loop than you do threads parallelising more than one loop won't net you any speed. Thank you! Yes, `parallel` runs only

Re: Appending static arrays

2017-07-18 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-17 22:11, Nordlöw wrote: - under what name: append, concat or cat? append - add array or element to existing array concat (concatenate) - add to arrays (or element) together to create a new array Seems like this is a concatenation. But please avoid shortening the names. I vote

Re: How to init immutable static array?

2017-07-18 Thread Miguel L via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 07:31:22 UTC, Era Scarecrow wrote: On Tuesday, 18 July 2017 at 07:30:30 UTC, Era Scarecrow wrote: my_array[i]=some calculations(based on constants and n) i meant: tmp[i]=some calculations(based on constants and n) That does work, thanks.

Re: How to init immutable static array?

2017-07-18 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 07:30:30 UTC, Era Scarecrow wrote: my_array[i]=some calculations(based on constants and n) i meant: tmp[i]=some calculations(based on constants and n)

Re: How to init immutable static array?

2017-07-18 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 07:20:48 UTC, Miguel L wrote: Hi, I need help again. I have an immutable static array and i need to initialize its contents inside a for loop. Something like this: void f(int n)() { immutable float[n] my_array; for(int i=0;i

How to init immutable static array?

2017-07-18 Thread Miguel L via Digitalmars-d-learn
Hi, I need help again. I have an immutable static array and i need to initialize its contents inside a for loop. Something like this: void f(int n)() { immutable float[n] my_array; for(int i=0;i