Re: Monads compared to InputRanges?

2013-12-03 Thread Max Klyga
On 2013-12-04 01:53:39 +, Shammah Chancellor said: On 2013-12-03 23:49:47 +, Max Klyga said: On 2013-12-03 23:02:13 +, Shammah Chancellor said: On 2013-12-03 21:51:20 +, Max Klyga said: On 2013-12-03 02:45:44 +, Shammah Chancellor said: I'm not particularly familiar wi

Re: alias this leads to compilation error in one of two similar contexts

2013-12-03 Thread Carl Sturtivant
This is intended behavior change from 2.064. http://dlang.org/class#field-init [...] Kenji Hara Interesting, useful, and a surprise. Thank you!

Re: floating point comparison basics

2013-12-03 Thread ed
On Wednesday, 4 December 2013 at 01:52:09 UTC, bearophile wrote: H. S. Teoh: The first rule of floating-point comparisons is that you never use ==. So I suggested to disallow the == among FP numbers in D (and allow FP comparisons with "is" or with specialized functions, including one functi

Re: Monads compared to InputRanges?

2013-12-03 Thread Shammah Chancellor
On 2013-12-03 23:49:47 +, Max Klyga said: On 2013-12-03 23:02:13 +, Shammah Chancellor said: On 2013-12-03 21:51:20 +, Max Klyga said: On 2013-12-03 02:45:44 +, Shammah Chancellor said: I'm not particularly familiar with the syntax being used in the variet of monad examples

Re: floating point comparison basics

2013-12-03 Thread bearophile
H. S. Teoh: The first rule of floating-point comparisons is that you never use ==. So I suggested to disallow the == among FP numbers in D (and allow FP comparisons with "is" or with specialized functions, including one function that does what == does today). For the original poster, for

Re: How to install dmd2 in centos 5.3 x64

2013-12-03 Thread Puming
On Tuesday, 3 December 2013 at 17:47:47 UTC, Dejan Lekic wrote: On Tuesday, 3 December 2013 at 10:43:06 UTC, Puming wrote: Hi: I followed the steps in http://dlang.org/dmd-linux.html, but when I build a simple hello world program with: rdmd hello.d I get the following error: rdmd hello.d /

Re: floating point comparison basics

2013-12-03 Thread ed
On Tuesday, 3 December 2013 at 23:17:29 UTC, H. S. Teoh wrote: Thanks for the reply and the link, it gives me more confidence that I'm understanding things a bit better. I finally feel like I've opened the lid on the black box of float precision. I found a great set of articles which I'm work

Re: Monads compared to InputRanges?

2013-12-03 Thread Max Klyga
On 2013-12-03 23:02:13 +, Shammah Chancellor said: On 2013-12-03 21:51:20 +, Max Klyga said: On 2013-12-03 02:45:44 +, Shammah Chancellor said: I'm not particularly familiar with the syntax being used in the variet of monad examples. I'm trying to figure out how this is differe

Re: Monads compared to InputRanges?

2013-12-03 Thread Timon Gehr
On 12/04/2013 12:02 AM, Shammah Chancellor wrote: I get the gist of that, but it seems like the range concept with UFCS provides the same thing? E.G. range.map().flatten().map()? Well, informally speaking, this is roughly an instance of a Monad. Does it really not accomplish the same thing

Re: floating point comparison basics

2013-12-03 Thread ed
OK, I've had a look into the code in std.math finally understand it, I think. I was confused about maxRelativeError and maxAbsoluteError then I found this also: http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm (...If you want to count numbers near zero but of opposite s

Re: floating point comparison basics

2013-12-03 Thread H. S. Teoh
On Tue, Dec 03, 2013 at 11:03:48PM +0100, ed wrote: > Hi All, > > I'm learning programming and chose D because it is the best :D But, > I've hit floating point numbers and I'm stuck on some of the basics. > > What is the proper way to do floating point comparisons, in > particular I need to check

Re: Monads compared to InputRanges?

2013-12-03 Thread Shammah Chancellor
On 2013-12-03 21:51:20 +, Max Klyga said: On 2013-12-03 02:45:44 +, Shammah Chancellor said: I'm not particularly familiar with the syntax being used in the variet of monad examples. I'm trying to figure out how this is different from UFCS on InputRanges. It seems like std.algorit

floating point comparison basics

2013-12-03 Thread ed
Hi All, I'm learning programming and chose D because it is the best :D But, I've hit floating point numbers and I'm stuck on some of the basics. What is the proper way to do floating point comparisons, in particular I need to check if a value is zero? For example, given "real x = someCalcu

Re: Monads compared to InputRanges?

2013-12-03 Thread Max Klyga
On 2013-12-03 02:45:44 +, Shammah Chancellor said: I'm not particularly familiar with the syntax being used in the variet of monad examples. I'm trying to figure out how this is different from UFCS on InputRanges. It seems like std.algorithm implements something which accomplished the

Re: stdout - autoflushing

2013-12-03 Thread Adam D. Ruppe
On Tuesday, 3 December 2013 at 20:36:22 UTC, Benji wrote: I am using Xubuntu, 64bit, and GDC as compiler Any IDE? I've seen ide consoles buffer differently because the runtime sees the target as a pipe instead of a user-interactive terminal.

Re: stdout - autoflushing

2013-12-03 Thread Jesse Phillips
On Tuesday, 3 December 2013 at 20:36:22 UTC, Benji wrote: On Tuesday, 3 December 2013 at 19:33:47 UTC, Ali Çehreli wrote: On 12/03/2013 09:12 AM, Benji wrote: Hello, in order to have correctly displayed output (before reading something from stdin), I must call stdout.flush(). I am surprised

Re: stdout - autoflushing

2013-12-03 Thread Ali Çehreli
On 12/03/2013 12:36 PM, Benji wrote: On Tuesday, 3 December 2013 at 19:33:47 UTC, Ali Çehreli wrote: On 12/03/2013 09:12 AM, Benji wrote: Hello, in order to have correctly displayed output (before reading something from stdin), I must call stdout.flush(). I am surprised that you need that. Wh

Re: stdout - autoflushing

2013-12-03 Thread Benji
On Tuesday, 3 December 2013 at 19:33:47 UTC, Ali Çehreli wrote: On 12/03/2013 09:12 AM, Benji wrote: Hello, in order to have correctly displayed output (before reading something from stdin), I must call stdout.flush(). I am surprised that you need that. What is your platform? Normally, stdi

Re: Freeing memory from C

2013-12-03 Thread Chris
On Tuesday, 3 December 2013 at 16:52:29 UTC, Ali Çehreli wrote: On 12/03/2013 06:45 AM, Chris wrote: > I became aware of uninitialized variable. I think that the latter > behavior is the correct one (segfault > crash). But why did it work > correctly in the other D program, how did the C variabl

Re: stdout - autoflushing

2013-12-03 Thread Ali Çehreli
On 12/03/2013 09:12 AM, Benji wrote: Hello, in order to have correctly displayed output (before reading something from stdin), I must call stdout.flush(). I am surprised that you need that. What is your platform? Normally, stdin and stdout are "tied". Reading from stdin flushes stdout automat

Re: stdout - autoflushing

2013-12-03 Thread Benji
On Tuesday, 3 December 2013 at 17:49:32 UTC, H. S. Teoh wrote: On Tue, Dec 03, 2013 at 06:12:20PM +0100, Benji wrote: Hello, in order to have correctly displayed output (before reading something from stdin), I must call stdout.flush(). Sometimes, it's really annoying, especially when it is nece

Re: How to install dmd2 in centos 5.3 x64

2013-12-03 Thread Dejan Lekic
On Tuesday, 3 December 2013 at 10:43:06 UTC, Puming wrote: Hi: I followed the steps in http://dlang.org/dmd-linux.html, but when I build a simple hello world program with: rdmd hello.d I get the following error: rdmd hello.d /usr/bin/ld: cannot find -l:libphobos2.a I have copied dmd2/linux

Re: stdout - autoflushing

2013-12-03 Thread H. S. Teoh
On Tue, Dec 03, 2013 at 06:12:20PM +0100, Benji wrote: > Hello, > in order to have correctly displayed output (before reading > something from stdin), > I must call stdout.flush(). > Sometimes, it's really annoying, especially when it is necessarry to > call it 10 times. > > For example: > write("

stdout - autoflushing

2013-12-03 Thread Benji
Hello, in order to have correctly displayed output (before reading something from stdin), I must call stdout.flush(). Sometimes, it's really annoying, especially when it is necessarry to call it 10 times. For example: write("Enter some string: "); stdout.flush(); string a = readln(); write("A

Thread affinity?

2013-12-03 Thread Rob T
In core.thread I don't see a portable way to pin a thread to a specific core, or at least pin the thread to whatever core it is currently running in. I found this solution, but it's for Windows only. http://www.gamedev.net/blog/1140/entry-2254424-setting-thread-affinity-on-windows-in-d/ I can

Re: Freeing memory from C

2013-12-03 Thread Ali Çehreli
On 12/03/2013 06:45 AM, Chris wrote: > I became aware of uninitialized variable. I think that the latter > behavior is the correct one (segfault > crash). But why did it work > correctly in the other D program, how did the C variable get initialized? Undefined behavior sometimes manifests itself

Re: Is anything private by default when declared in a module?

2013-12-03 Thread eles
On Monday, 2 December 2013 at 21:28:48 UTC, lomereiter wrote: On Monday, 2 December 2013 at 20:53:10 UTC, Namespace wrote: OMG now I get it why in 2.064 importing std.regex makes visible std.uni.isWhite all of a sudden. Unicorns cannot be white, as they are already pink & invisible. At leas

Re: Is anything private by default when declared in a module?

2013-12-03 Thread H. S. Teoh
On Tue, Dec 03, 2013 at 04:16:04PM +0100, Adam D. Ruppe wrote: [...] > BTW private names should be outright invisible outside the module. > At least private things at module scope. I get really annoyed with > "public symbol foo from module bar conflicts with private symbol foo > from module baz". G

Re: Is anything private by default when declared in a module?

2013-12-03 Thread Adam D. Ruppe
On Tuesday, 3 December 2013 at 07:34:37 UTC, Jonathan M Davis wrote: They create a conflicting symbol in the importing module's scope. That's why you should never use them at this point. Well, that's sometimes useful, it helps get rid of conflict errors quickly, easily, and explicitly. It s

Re: Freeing memory from C

2013-12-03 Thread Adam D. Ruppe
On Tuesday, 3 December 2013 at 12:43:08 UTC, bearophile wrote: You can file an enhancement request for the documentation, or fix the docs yourself. https://github.com/D-Programming-Language/dlang.org/pull/427

Re: How to install dmd2 in centos 5.3 x64

2013-12-03 Thread Jordi Sayol
El 03/12/13 14:10, Puming ha escrit: > On Tuesday, 3 December 2013 at 11:17:27 UTC, Jordi Sayol wrote: >> El 03/12/13 11:43, Puming ha escrit: >>> Hi: >>> >>> I followed the steps in http://dlang.org/dmd-linux.html, but when I build a >>> simple hello world program with: >>> >>> rdmd hello.d >>> >

Re: Freeing memory from C

2013-12-03 Thread Chris
On Tuesday, 3 December 2013 at 14:18:35 UTC, John Colvin wrote: On Tuesday, 3 December 2013 at 13:05:20 UTC, Mike Parker wrote: On 12/3/2013 9:31 PM, John Colvin wrote: You should be fine to free in that way as long as you haven't done anything crazy like separately static linking libc. I

Re: Freeing memory from C

2013-12-03 Thread Chris
On Tuesday, 3 December 2013 at 13:05:20 UTC, Mike Parker wrote: On 12/3/2013 9:31 PM, John Colvin wrote: You should be fine to free in that way as long as you haven't done anything crazy like separately static linking libc. I wouldn't advise this in the general case. When you have complet

Re: Freeing memory from C

2013-12-03 Thread John Colvin
On Tuesday, 3 December 2013 at 13:05:20 UTC, Mike Parker wrote: On 12/3/2013 9:31 PM, John Colvin wrote: You should be fine to free in that way as long as you haven't done anything crazy like separately static linking libc. I wouldn't advise this in the general case. When you have complet

Re: How to install dmd2 in centos 5.3 x64

2013-12-03 Thread Puming
On Tuesday, 3 December 2013 at 11:17:27 UTC, Jordi Sayol wrote: El 03/12/13 11:43, Puming ha escrit: Hi: I followed the steps in http://dlang.org/dmd-linux.html, but when I build a simple hello world program with: rdmd hello.d I get the following error: rdmd hello.d /usr/bin/ld: cannot fin

Re: Freeing memory from C

2013-12-03 Thread Mike Parker
On 12/3/2013 9:31 PM, John Colvin wrote: You should be fine to free in that way as long as you haven't done anything crazy like separately static linking libc. I wouldn't advise this in the general case. When you have complete end-to-end control, sure. But if, for example, you're using a dyn

Re: How to install dmd2 in centos 5.3 x64

2013-12-03 Thread Puming
On Tuesday, 3 December 2013 at 11:10:13 UTC, lomereiter wrote: Did you install binaries or build the compiler from source? I used the dmd.2.064.2.zip, because when I install the rpm binary, it says there are dependency issues.

Re: Freeing memory from C

2013-12-03 Thread bearophile
Chris: std.c.stdlib.free() is mentioned on the "How to interface to C" page (http://dlang.org/interfaceToC.html). So maybe that needs an update. You can file an enhancement request for the documentation, or fix the docs yourself. I'll file a little bug report for the other library deprecat

Re: Freeing memory from C

2013-12-03 Thread Chris
On Tuesday, 3 December 2013 at 12:31:16 UTC, John Colvin wrote: On Tuesday, 3 December 2013 at 10:57:51 UTC, Chris wrote: I have a C module that dynamically allocates memory for a string like so: char *result = (char*)malloc(length + 1); // 'length' has been calculated When I call it from D

Re: Freeing memory from C

2013-12-03 Thread John Colvin
On Tuesday, 3 December 2013 at 10:57:51 UTC, Chris wrote: I have a C module that dynamically allocates memory for a string like so: char *result = (char*)malloc(length + 1); // 'length' has been calculated When I call it from D (via extern (C)), is it ok to free it from there like so: voi

Re: How to install dmd2 in centos 5.3 x64

2013-12-03 Thread Jordi Sayol
El 03/12/13 11:43, Puming ha escrit: > Hi: > > I followed the steps in http://dlang.org/dmd-linux.html, but when I build a > simple hello world program with: > > rdmd hello.d > > I get the following error: > > rdmd hello.d > /usr/bin/ld: cannot find -l:libphobos2.a > > I have copied dmd2/linu

Re: How to install dmd2 in centos 5.3 x64

2013-12-03 Thread lomereiter
Did you install binaries or build the compiler from source?

Freeing memory from C

2013-12-03 Thread Chris
I have a C module that dynamically allocates memory for a string like so: char *result = (char*)malloc(length + 1); // 'length' has been calculated When I call it from D (via extern (C)), is it ok to free it from there like so: void callFunction() { auto result = callToCFunction(); // Re

How to install dmd2 in centos 5.3 x64

2013-12-03 Thread Puming
Hi: I followed the steps in http://dlang.org/dmd-linux.html, but when I build a simple hello world program with: rdmd hello.d I get the following error: rdmd hello.d /usr/bin/ld: cannot find -l:libphobos2.a I have copied dmd2/linux/lib64/libphobos2.a to /usr/lib64, but ld still can't find

Re: Associative array references

2013-12-03 Thread Atila Neves
On Monday, 2 December 2013 at 16:52:51 UTC, bearophile wrote: Atila Neves: How would that go in this case? An example usage: void main() { int[float][string] aa; aa["foo"][1.5] = 1; } Bye, bearophile Oh. That makes sense. Doh! I guess I was focussing on "key to AA of..." and that

Re: Associative array references

2013-12-03 Thread Atila Neves
On Tuesday, 3 December 2013 at 03:14:46 UTC, Jesse Phillips wrote: On Monday, 2 December 2013 at 13:30:44 UTC, Atila Neves wrote: It seems that assigning an AA to another makes both point at the same data only if the first array has data to begin with. Is that the expected behaviour? Atila

Re: enum value vs. immutable

2013-12-03 Thread Maxim Fomin
On Tuesday, 3 December 2013 at 08:28:23 UTC, Ali Çehreli wrote: That works for some types as both enum and immutable have their problems: * enum is no good for arrays and AAs as it is very likely to be unnecessarily slow. * immutable is no good for types that contain mutable references at

Re: Monads compared to InputRanges?

2013-12-03 Thread Ali Çehreli
On 12/02/2013 06:45 PM, Shammah Chancellor wrote: > I'm not particularly familiar with the syntax being used in the variet > of monad examples. I'm trying to figure out how this is different from > UFCS on InputRanges. It seems like std.algorithm implements something > which accomplished the

Re: enum value vs. immutable

2013-12-03 Thread Ali Çehreli
On 12/01/2013 11:48 PM, Maxim Fomin wrote: >> 1) Prefer enum first because enum values can be used for template >> instantiations. > > You can instatiate templates not only with enums. Main pro for enums is > that they are CT values. The confusion is, some const values are CT values as well. >>

Re: equivalent of python join?

2013-12-03 Thread Ali Çehreli
On 12/02/2013 11:32 PM, Jacob Carlborg wrote: > On 2013-12-03 07:36, CJS wrote: >> In python a common performance tip for joining many strings together is >> to use the join method. So, for example, instead of >> "a" + "b" + "c" >> use >> ''.join(["a","b","c"]). >> The idea is to avoid creating t