Re: Pacikage level access broken?

2012-04-22 Thread Jacob Carlborg
On 2012-04-23 01:21, Era Scarecrow wrote: I think I have a misunderstanding of how 'package' is suppose to work. How I understand it, you will give access to the directory, unlike private which will hide it outside of the same file. This problem comes up since a struct is declared inside a packa

Re: Passing a function (with arguments) as function input

2012-04-22 Thread Jakob Ovrum
On Sunday, 22 April 2012 at 23:19:52 UTC, Joseph Rushton Wakeling wrote: import std.random, std.range, std.stdio; void printRandomNumbers(RandomNumberGenerator)(RandomNumberGenerator rng, size_t n) { foreach(i; 0..n) write

Re: avoid toLower in std.algorithm.sort compare alias

2012-04-22 Thread Jay Norwood
On Sunday, 22 April 2012 at 00:36:19 UTC, bearophile wrote: Performing the toLower every time the cmp function is called doesn't change the O complexity. In Phobos there is an alternative sorting (Schwartzian sorting routime) that applies a function to each item before sorting them, usually is

Re: Passing a function (with arguments) as function input

2012-04-22 Thread Joseph Rushton Wakeling
On 23/04/12 06:10, Ali Çehreli wrote: You just need to call the delegate with the function call syntax: writeln(rng()); ... but what I get in my code is that printRandomNumbers then prints out n times the _same number_, instead of 5 different ones. i.e. when the delegate is passed its retur

Re: Passing a function (with arguments) as function input

2012-04-22 Thread Ali Çehreli
On 04/22/2012 04:19 PM, Joseph Rushton Wakeling wrote: Is there a way in which to pass a function as input to another function, with the arguments of the first function already determined? The case I'm thinking of is one where I have a function which wants to take a random number generation sche

Re: Issue calling methods using std.concurrency

2012-04-22 Thread Ali Çehreli
On 04/22/2012 07:15 PM, Casey wrote: Hello, I'm getting some errors when I wrap a struct that I've written with another struct. Here are the errors I'm getting: tqueue.d(14): Error: function queue.Queue!(int).Queue.enqueue (int value) is not callable using argument types (int) shared tqueue.d(1

Issue calling methods using std.concurrency

2012-04-22 Thread Casey
Hello, I'm getting some errors when I wrap a struct that I've written with another struct. Here are the errors I'm getting: tqueue.d(14): Error: function queue.Queue!(int).Queue.enqueue (int value) is not callable using argument types (int) shared tqueue.d(15): Error: function queue.Queue!

Re: Question about arrays

2012-04-22 Thread Ali Çehreli
On 04/22/2012 03:17 PM, Stephen Jones wrote: > Thanks for the replies. I am still uncertain about something. The > documentation distinguishes between dynamic slices (int[5] a = new > int[5]) The documentation may be incorrect because int[5] is never a slice. It is a fixed-length array. As an

Re: opPropDispatch

2012-04-22 Thread Jonathan M Davis
On Monday, April 23, 2012 02:40:42 Adam D. Ruppe wrote: > On Sunday, 22 April 2012 at 23:54:17 UTC, Jonathan M Davis wrote: > > Well, strict enforcement is how @property was designed in the > > first place (and is how it's described in TDPL). > > That doesn't affect my argument at all, > > People

Re: opPropDispatch

2012-04-22 Thread Adam D. Ruppe
On Sunday, 22 April 2012 at 23:54:17 UTC, Jonathan M Davis wrote: Well, strict enforcement is how @property was designed in the first place (and is how it's described in TDPL). That doesn't affect my argument at all, People actually use the implementation as it is, which is a superset of the T

Re: Package level access broken?

2012-04-22 Thread Jonathan M Davis
On Monday, April 23, 2012 01:59:15 Era Scarecrow wrote: > On Sunday, 22 April 2012 at 23:32:40 UTC, Jonathan M Davis wrote: > > 1. Package access is _very_ broken: > > http://d.puremagic.com/issues/show_bug.cgi?id=143 > > Fun... So it's not just me... Guess for the 1-2 places I 'll > need packag

Range of n random numbers

2012-04-22 Thread Joseph Rushton Wakeling
Related to my earlier question -- I was wondering if there's a trivial way of generating a range of n random numbers according to a given distribution and parameters. I wrote up the code below to generate a range of n uniformly-distributed numbers, but am not sure how to generalize it for arbi

Re: Package level access broken?

2012-04-22 Thread Era Scarecrow
On Sunday, 22 April 2012 at 23:32:40 UTC, Jonathan M Davis wrote: 1. Package access is _very_ broken: http://d.puremagic.com/issues/show_bug.cgi?id=143 Fun... So it's not just me... Guess for the 1-2 places I 'll need package level access instead I gotta either do public or get some getters

Re: opPropDispatch

2012-04-22 Thread Jonathan M Davis
On Monday, April 23, 2012 01:39:44 Adam D. Ruppe wrote: > On Sunday, 22 April 2012 at 23:21:57 UTC, Jonathan M Davis wrote: > > Well, I completely disagree with you on @property. > > Note: my problem is with -property, not @property. > > If @property was correctly implemented, it'd serve > a very

Re: opPropDispatch

2012-04-22 Thread Adam D. Ruppe
On Sunday, 22 April 2012 at 23:21:57 UTC, Jonathan M Davis wrote: Well, I completely disagree with you on @property. Note: my problem is with -property, not @property. If @property was correctly implemented, it'd serve a very nice purpose. The reason I'm aware of the bug is this is something I

Re: Pacikage level access broken?

2012-04-22 Thread Jonathan M Davis
On Monday, April 23, 2012 01:21:21 Era Scarecrow wrote: > I think I have a misunderstanding of how 'package' is suppose to > work. How I understand it, you will give access to the directory, > unlike private which will hide it outside of the same file. 1. Package access is _very_ broken: http:/

Re: Question about arrays

2012-04-22 Thread jerro
On Sunday, 22 April 2012 at 23:01:26 UTC, jerro wrote: On Sunday, 22 April 2012 at 22:17:11 UTC, Stephen Jones wrote: Thanks for the replies. I am still uncertain about something. The documentation distinguishes between dynamic slices (int[5] a = new int[5]) which are managed by the runtime, an

Re: Passing a function (with arguments) as function input

2012-04-22 Thread Joseph Rushton Wakeling
On 23/04/12 01:19, Joseph Rushton Wakeling wrote: void main() { foreach(double upper; iota(1.0, 2.0, 0.2) ) { double delegate() rng = () { return uniform(0.0, 1.0); }; printRandomNumbers(rng,10); } } That was meant to be, double delegate() rng =

Pacikage level access broken?

2012-04-22 Thread Era Scarecrow
I think I have a misunderstanding of how 'package' is suppose to work. How I understand it, you will give access to the directory, unlike private which will hide it outside of the same file. This problem comes up since a struct is declared inside a package (and even instantiated), however ac

Re: opPropDispatch

2012-04-22 Thread Jonathan M Davis
On Monday, April 23, 2012 01:01:48 Adam D. Ruppe wrote: > On Sunday, 22 April 2012 at 22:36:12 UTC, Jonathan M Davis wrote: > > Eventually -property will be the normal behavior. > > Note that -property adds zero value, much like the current > implementation of @property, which fails to disambiguat

Passing a function (with arguments) as function input

2012-04-22 Thread Joseph Rushton Wakeling
Is there a way in which to pass a function as input to another function, with the arguments of the first function already determined? The case I'm thinking of is one where I have a function which wants to take a random number generation scheme, and use it on several occasions, without having a

Re: opPropDispatch

2012-04-22 Thread Adam D. Ruppe
On Sunday, 22 April 2012 at 22:36:12 UTC, Jonathan M Davis wrote: Eventually -property will be the normal behavior. Note that -property adds zero value, much like the current implementation of @property, which fails to disambiguate cases: == import std.stdio; alias void delegate() callable;

Re: Question about arrays

2012-04-22 Thread jerro
On Sunday, 22 April 2012 at 22:17:11 UTC, Stephen Jones wrote: Thanks for the replies. I am still uncertain about something. The documentation distinguishes between dynamic slices (int[5] a = new int[5]) which are managed by the runtime, and stack allocated arrays (int[5] b). The problem I have

Re: opPropDispatch

2012-04-22 Thread Jonathan M Davis
On Sunday, April 22, 2012 22:30:01 David wrote: > For now you can do it *without* @property and compile *without* -property But that will not remain the case, so relying on that is not a good idea. Eventually -property will be the normal behavior. As for opPropDispatch, I don't think that it's s

Re: Question about arrays

2012-04-22 Thread Stephen Jones
Thanks for the replies. I am still uncertain about something. The documentation distinguishes between dynamic slices (int[5] a = new int[5]) which are managed by the runtime, and stack allocated arrays (int[5] b). The problem I have is this. I want to be loading vertex positions and tex-coords

Re: What am I doing wrong ?

2012-04-22 Thread SomeDude
On Sunday, 22 April 2012 at 21:50:32 UTC, Dmitry Olshansky wrote: Omagad, thank you, too much Java is bd for your brains.

Re: What am I doing wrong ?

2012-04-22 Thread Mike Wey
On 04/22/2012 11:47 PM, SomeDude wrote: Sorry for the noob questions, but import std.stdio; struct Foo { int x; } void main() { auto array = new Foo[10]; auto i = array.length; foreach(Foo f; array) { f.x = --i; write(f.x);} Use ref when you want to modify the original array, without ref you

Re: What am I doing wrong ?

2012-04-22 Thread Dmitry Olshansky
On 23.04.2012 1:47, SomeDude wrote: Sorry for the noob questions, but import std.stdio; struct Foo { int x; } void main() { auto array = new Foo[10]; auto i = array.length; foreach(Foo f; array) { f.x = --i; write(f.x);} writeln(); foreach(Foo f; array) { write(f.x);} Here: Foo f is not a ref

What am I doing wrong ?

2012-04-22 Thread SomeDude
Sorry for the noob questions, but import std.stdio; struct Foo { int x; } void main() { auto array = new Foo[10]; auto i = array.length; foreach(Foo f; array) { f.x = --i; write(f.x);} writeln(); foreach(Foo f; array) { write(f.x);} } gives me: PS E:\DigitalMars\dmd2\sa

Re: avoid toLower in std.algorithm.sort compare alias

2012-04-22 Thread SomeDude
On Saturday, 21 April 2012 at 23:24:57 UTC, Jay Norwood wrote: While playing with sorting the unzip archive entries I tried use of the last example in http://dlang.org/phobos/std_algorithm.html#sort std.algorithm.sort!("toLower(a.name) < toLower(b.name)",std.algorithm.SwapStrategy.stable)(ent

Re: this() const

2012-04-22 Thread sclytrack
On 04/16/2012 09:27 PM, sclytrack wrote: On 04/16/2012 08:15 PM, sclytrack wrote: const numbers = new int[2]; const c = const(AB)(a, 20, numbers); writeln(c); } Bye, bearophile That's exactly what I needed, thanks. Seems to be forwarded to the constructor if there is one. (untested code

Re: opPropDispatch

2012-04-22 Thread David
Am 22.04.2012 22:11, schrieb sclytrack: struct Dispatcher { @property void opDispatch(string name)(string val) { writeln(val); } @property string opDispatch(string name)() { return "getter"; } void opDispatch(string name)() { writeln(name); } } I can't seem to make a "dispatcher" that suppo

opPropDispatch

2012-04-22 Thread sclytrack
struct Dispatcher { @property void opDispatch(string name)(string val) { writeln(val); } @property string opDispatch(string name)() { return "getter"; } void opDispatch(strin

Re: Module zlib cannot be read

2012-04-22 Thread Joseph Rushton Wakeling
On 22/04/12 19:18, Jesse Phillips wrote: On Sunday, 22 April 2012 at 15:26:34 UTC, Joseph Rushton Wakeling wrote: /usr/local/include/d2/std/zlib.d(26): Error: module zlib is in file 'etc/c/zlib.d' which cannot be read import path[0] = /usr/local/include/d2/ Do you see the file: /usr/local/inc

Re: Module zlib cannot be read

2012-04-22 Thread Jesse Phillips
On Sunday, 22 April 2012 at 15:26:34 UTC, Joseph Rushton Wakeling wrote: /usr/local/include/d2/std/zlib.d(26): Error: module zlib is in file 'etc/c/zlib.d' which cannot be read import path[0] = /usr/local/include/d2/ Do you see the file: /usr/local/include/d2/etc/c/zlib.d ? If not, then

Re: Keyword to avoid not null references

2012-04-22 Thread Jesse Phillips
On Saturday, 21 April 2012 at 22:18:02 UTC, Adam D. Ruppe wrote: We can do not null in the library reasonably well. I have a basic one in github: https://github.com/D-Programming-Language/phobos/pull/477 I'm thinking those interested in not null will want something similar to the maybe type.

Module zlib cannot be read

2012-04-22 Thread Joseph Rushton Wakeling
Hello all, I currently have a self-compiled and installed dmd, druntime, phobos and rdmd on Ubuntu 12.04. I get the following error message whenever I try to use rdmd or equivalently dmd -run: /usr/local/include/d2/std/zlib.d(26): Error: module zlib is in file 'etc/c/zlib.d' which cannot

Re: Keyword to avoid not null references

2012-04-22 Thread Namespace
On Sunday, 22 April 2012 at 00:06:47 UTC, Adam D. Ruppe wrote: I just pushed an update to git with a few changes people have suggested. I removed one of the old opAssigns to keep a static type check. Added assumeNotNull and checkNotNull as entry points. I didn't recognized this part until now

Re: avoid toLower in std.algorithm.sort compare alias

2012-04-22 Thread Jacob Carlborg
On 2012-04-22 01:24, Jay Norwood wrote: While playing with sorting the unzip archive entries I tried use of the last example in http://dlang.org/phobos/std_algorithm.html#sort std.algorithm.sort!("toLower(a.name) < toLower(b.name)",std.algorithm.SwapStrategy.stable)(entries); It was terribly sl

Re: Access violation using chain()

2012-04-22 Thread Brad Anderson
On Thursday, 19 April 2012 at 16:19:05 UTC, Brad Anderson wrote: On Thu, Apr 19, 2012 at 7:25 AM, Christophe wrote: "Brad Anderson" , dans le message (digitalmars.D.learn:34902), a écrit : > Perhaps I'm just misunderstanding something about closures > but > the following code seems to behave

Re: toLower() and Unicode are incomplete was: Re: avoid toLower in std.algorithm.sort compare alias

2012-04-22 Thread Dmitry Olshansky
On 22.04.2012 5:43, Ali Çehreli wrote: On 04/21/2012 04:24 PM, Jay Norwood wrote: > While playing with sorting the unzip archive entries I tried use of the > last example in http://dlang.org/phobos/std_algorithm.html#sort > > std.algorithm.sort!("toLower(a.name) < > toLower(b.name)",std.algo

Re: Keyword to avoid not null references

2012-04-22 Thread Namespace
On Sunday, 22 April 2012 at 00:06:47 UTC, Adam D. Ruppe wrote: Made the data member private. But if the struct is in a separate module you get an error. So you must write T get() { return this._notNullData; } alias get this; instead alias _notNullData this; /// this is subst

Re: Regarding the more precise GC

2012-04-22 Thread Dmitry Olshansky
On 22.04.2012 4:28, bearophile wrote: In the main D newsgroup I have seen the two recent threads regarding a more precise GC in D. I have two questions about that, that seem more fit for D.learn. 1) I have not fully understood the performance and memory implications of the more precise GC. In th

Re: Keyword to avoid not null references

2012-04-22 Thread Namespace
On Sunday, 22 April 2012 at 00:06:47 UTC, Adam D. Ruppe wrote: I just pushed an update to git with a few changes people have suggested. I removed one of the old opAssigns to keep a static type check. Added assumeNotNull and checkNotNull as entry points. Made the data member private. I think

Re: avoid toLower in std.algorithm.sort compare alias

2012-04-22 Thread Jay Norwood
On Sunday, 22 April 2012 at 06:26:42 UTC, Jonathan M Davis wrote: You can look at the code. It checks each of the characters in place. Unlike toLower, it doesn't need to generate a new string. But as far as the comparison goes, they're the same - hence that line in the docs. - Jonathan M Dav