Re: Is this rdmd bug or my fault ?

2016-01-16 Thread zabruk70 via Digitalmars-d-learn
Can anybody explain: Is dependencies file produced from command: dmd -deps=moduleA.deps moduleA.d must contains mention of moduleC? Is dependencies file produced reccursively? Thanks.

Re: Voldemort Type Construction Error

2016-01-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, January 16, 2016 06:06:03 Kapps via Digitalmars-d-learn wrote: > On Friday, 15 January 2016 at 20:04:47 UTC, Nordlöw wrote: > > On Friday, 15 January 2016 at 16:51:24 UTC, Anon wrote: > >> On Friday, 15 January 2016 at 14:04:50 UTC, Nordlöw wrote: > >>> What have I missed? > >> > >>

Re: c style casts

2016-01-16 Thread Warwick via Digitalmars-d-learn
On Friday, 15 January 2016 at 15:13:37 UTC, Jacob Carlborg wrote: On 2016-01-15 11:16, Warwick wrote: I though C style casts were not supported? But when I accidentaly did int i; if (uint(i) < length) it compiled and worked fine. Whys that? Wouldn't a C style cast be: int i; if

Convert some ints into a byte array without allocations?

2016-01-16 Thread Samson Smith via Digitalmars-d-learn
I'm trying to make a fast little function that'll give me a random looking (but deterministic) value from an x,y position on a grid. I'm just going to run each co-ord that I need through an FNV-1a hash function as an array of bytes since that seems like a fast and easy way to go. I'm going to

Re: Functions that return type

2016-01-16 Thread Timon Gehr via Digitalmars-d-learn
On 01/16/2016 11:50 PM, data pulverizer wrote: I guess the constraints are that of a static language. (This is not true.)

Re: DUB - link error on Windows 10 64-bit

2016-01-16 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 16 January 2016 at 20:28:02 UTC, Dibyendu Majumdar wrote: I have installed DMD by unzipping the DMD archive (The installer does not work correctly on Windows 10). DUB installed as normal. What problem did you have with the installer? Which version? I've installed DMD more

Re: DUB - link error on Windows 10 64-bit

2016-01-16 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 17 January 2016 at 02:48:47 UTC, Mike Parker wrote: On Saturday, 16 January 2016 at 20:28:02 UTC, Dibyendu Majumdar wrote: I have installed DMD by unzipping the DMD archive (The installer does not work correctly on Windows 10). DUB installed as normal. What problem did you

Re: Functions that return type

2016-01-16 Thread Ali Çehreli via Digitalmars-d-learn
On 01/16/2016 02:50 PM, data pulverizer wrote: > I guess I have been writing a lot of julia where I take > creating arrays and tuples of types for granted. In this case > types are of type DataType. [...] I guess the constraints are > that of a static language. Exactly. I am sure every D

Question about OutputRange and std.range: put

2016-01-16 Thread Uranuz via Digitalmars-d-learn
Hello to forum readers! I have a question about using OutputRange and std.range: put. I have the following code snippet to illustrate my question: import std.range, std.stdio, std.string; void main() { string greating = "Hello, " ; string username = "Bob";

Re: Convert some ints into a byte array without allocations?

2016-01-16 Thread Samson Smith via Digitalmars-d-learn
On Saturday, 16 January 2016 at 15:42:39 UTC, bearophile wrote: Yazan D: On Saturday, 16 January 2016 at 14:42:27 UTC, Yazan D wrote: ubyte[] b = (cast(ubyte*) )[0 .. int.sizeof]; Better to use the actual size: ubyte[] b = (cast(ubyte*) )[0 .. a.sizeof]; Bye, bearophile Good thinking, I

Re: Question about OutputRange and std.range: put

2016-01-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, January 16, 2016 12:11:11 Uranuz via Digitalmars-d-learn wrote: > Hello to forum readers! > I have a question about using OutputRange and std.range: put. I > have the following code snippet to illustrate my question: > > import std.range, std.stdio, std.string; > > void main() > { >

Re: Convert some ints into a byte array without allocations?

2016-01-16 Thread Samson Smith via Digitalmars-d-learn
On Saturday, 16 January 2016 at 14:42:27 UTC, Yazan D wrote: On Sat, 16 Jan 2016 14:34:54 +, Samson Smith wrote: [...] You can do this: ubyte[] b = (cast(ubyte*) )[0 .. int.sizeof]; It is casting the pointer to `a` to a ubyte (or byte) pointer and then taking a slice the size of int.

Re: Question about OutputRange and std.range: put

2016-01-16 Thread Uranuz via Digitalmars-d-learn
On Saturday, 16 January 2016 at 16:14:56 UTC, Jonathan M Davis wrote: On Saturday, January 16, 2016 12:11:11 Uranuz via Digitalmars-d-learn wrote: [...] There are a few problems here. First off, when put is used with an array, it fills the array. It doesn't append to it. So, you can't use a

Re: Question about OutputRange and std.range: put

2016-01-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, January 16, 2016 16:53:24 Uranuz via Digitalmars-d-learn wrote: > On Saturday, 16 January 2016 at 16:14:56 UTC, Jonathan M Davis > wrote: > > On Saturday, January 16, 2016 12:11:11 Uranuz via > > Digitalmars-d-learn wrote: > >> [...] > > > > There are a few problems here. First off,

Re: Convert some ints into a byte array without allocations?

2016-01-16 Thread Yazan D via Digitalmars-d-learn
On Sat, 16 Jan 2016 14:34:54 +, Samson Smith wrote: > I'm trying to make a fast little function that'll give me a random > looking (but deterministic) value from an x,y position on a grid. I'm > just going to run each co-ord that I need through an FNV-1a hash > function as an array of bytes

Re: Convert some ints into a byte array without allocations?

2016-01-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, January 16, 2016 14:34:54 Samson Smith via Digitalmars-d-learn wrote: > I'm trying to make a fast little function that'll give me a > random looking (but deterministic) value from an x,y position on > a grid. I'm just going to run each co-ord that I need through an > FNV-1a hash

Re: Convert some ints into a byte array without allocations?

2016-01-16 Thread Yazan D via Digitalmars-d-learn
On Sat, 16 Jan 2016 14:42:27 +, Yazan D wrote: > > You can do this: > ubyte[] b = (cast(ubyte*) )[0 .. int.sizeof]; > > It is casting the pointer to `a` to a ubyte (or byte) pointer and then > taking a slice the size of int. You can also use a union: union Foo { int i; ubyte[4] b; }

Re: Convert some ints into a byte array without allocations?

2016-01-16 Thread bearophile via Digitalmars-d-learn
Yazan D: On Saturday, 16 January 2016 at 14:42:27 UTC, Yazan D wrote: ubyte[] b = (cast(ubyte*) )[0 .. int.sizeof]; Better to use the actual size: ubyte[] b = (cast(ubyte*) )[0 .. a.sizeof]; Bye, bearophile

Re: Convert some ints into a byte array without allocations?

2016-01-16 Thread Samson Smith via Digitalmars-d-learn
On Saturday, 16 January 2016 at 16:28:21 UTC, Jonathan M Davis wrote: On Saturday, January 16, 2016 14:34:54 Samson Smith via Digitalmars-d-learn wrote: I'm trying to make a fast little function that'll give me a random looking (but deterministic) value from an x,y position on a grid. I'm just

Re: Convert some ints into a byte array without allocations?

2016-01-16 Thread Johannes Pfau via Digitalmars-d-learn
Am Sat, 16 Jan 2016 18:05:46 + schrieb Samson Smith : > On Saturday, 16 January 2016 at 16:28:21 UTC, Jonathan M Davis > wrote: > > > > But it will be less error-prone to use those functions, and if > > you _do_ actually need to swap endianness, then they're exactly > > what

Re: Functions that return type

2016-01-16 Thread data pulverizer 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; } More to the point what is the Type of a type such as int? Thanks p.s. I am aware I could do

Re: Functions that return type

2016-01-16 Thread rsw0x 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; } Functions return values, not types. You would use a template to "return" a type. More to

DUB - link error on Windows 10 64-bit

2016-01-16 Thread Dibyendu Majumdar via Digitalmars-d-learn
Hi I am using DUB on Windows 10 64-bit with DMD. I have simple project with following configuration: { "name": "testing", "description": "A minimal D application.", "copyright": "Copyright © 2016, dibyendu", "authors": ["dibyendu"], "targetType":

Re: DUB - link error on Windows 10 64-bit

2016-01-16 Thread Robert M. Münch via Digitalmars-d-learn
On 2016-01-16 20:28:02 +, Dibyendu Majumdar said: I have installed DMD by unzipping the DMD archive (The installer does not work correctly on Windows 10). DUB installed as normal. Check your paths in sc.ini Looks like the D link libraries are not found. -- Robert M. Münch

Re: Convert some ints into a byte array without allocations?

2016-01-16 Thread Johannes Pfau via Digitalmars-d-learn
Am Sat, 16 Jan 2016 15:46:00 + schrieb Samson Smith : > On Saturday, 16 January 2016 at 14:42:27 UTC, Yazan D wrote: > > On Sat, 16 Jan 2016 14:34:54 +, Samson Smith wrote: > > > >> [...] > > > > You can do this: > > ubyte[] b = (cast(ubyte*) )[0 .. int.sizeof]; > > > >

Functions that return type

2016-01-16 Thread data pulverizer via Digitalmars-d-learn
Is it possible to create a function that returns Type like typeof() does? Something such as: Type returnInt(){ return int; } More to the point what is the Type of a type such as int? Thanks

Re: Functions that return type

2016-01-16 Thread data pulverizer via Digitalmars-d-learn
On Saturday, 16 January 2016 at 21:59:22 UTC, data pulverizer wrote: 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; } More to the point what is

Re: Functions that return type

2016-01-16 Thread anonymous 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; } No. A function cannot return a type. A template can evaluate to a type, though:

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: Convert some ints into a byte array without allocations?

2016-01-16 Thread tsbockman via Digitalmars-d-learn
On Saturday, 16 January 2016 at 14:46:47 UTC, Yazan D wrote: You can also use a union: union Foo { int i; ubyte[4] b; } // write to int part Foo f = Foo(a); // then read from ubyte part writeln(foo.b); ps. I am not sure of the aliasing rules in D for unions. In C, this is allowed, but in

Re: DUB - link error on Windows 10 64-bit

2016-01-16 Thread Dibyendu Majumdar via Digitalmars-d-learn
On Saturday, 16 January 2016 at 20:50:51 UTC, Robert M. Münch wrote: Check your paths in sc.ini Looks like the D link libraries are not found. Well as far as I can tell they are correct (unchanged from whatever the installer set them to): ; environment for both 32/64 bit [Environment]

Re: DUB - link error on Windows 10 64-bit

2016-01-16 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 16 January 2016 at 21:51:15 UTC, Dibyendu Majumdar wrote: Well as far as I can tell they are correct (unchanged from whatever the installer set them to): ; environment for both 32/64 bit [Environment] DFLAGS="-I%@P%\..\..\src\phobos" "-I%@P%\..\..\src\druntime\import" ;

function argument accepting function or delegate?

2016-01-16 Thread Jon D via Digitalmars-d-learn
My underlying question is how to compose functions taking functions as arguments, while allowing the caller the flexibility to pass either a function or delegate. Simply declaring an argument as either a function or delegate seems to prohibit the other. Overloading works. Are there better

Re: function argument accepting function or delegate?

2016-01-16 Thread rsw0x via Digitalmars-d-learn
On Sunday, 17 January 2016 at 06:27:41 UTC, Jon D wrote: My underlying question is how to compose functions taking functions as arguments, while allowing the caller the flexibility to pass either a function or delegate. [...] Templates are an easy way. --- auto call(F, Args...)(F fun, auto

Re: function argument accepting function or delegate?

2016-01-16 Thread Jon D via Digitalmars-d-learn
On Sunday, 17 January 2016 at 06:49:23 UTC, rsw0x wrote: On Sunday, 17 January 2016 at 06:27:41 UTC, Jon D wrote: My underlying question is how to compose functions taking functions as arguments, while allowing the caller the flexibility to pass either a function or delegate. [...]