Re: Using in as a parameter qualifier

2013-05-31 Thread Ali Çehreli
On 05/30/2013 10:36 PM, Shriramana Sharma wrote: struct pair { It is more common to start type names with a capital letter: Pair. double x,y ; this () {} That is not allowed. In D, every type has the .init property, which is its default value. this (double x, double y) {

Re: Using in as a parameter qualifier

2013-05-31 Thread Shriramana Sharma
On Fri, May 31, 2013 at 12:12 PM, Ali Çehreli acehr...@yahoo.com wrote: double x,y ; this () {} That is not allowed. In D, every type has the .init property, which is its default value. Hm can you clarify that a bit? If I actually try it I get: pair.d(14): Error: constructor

Re: Using in as a parameter qualifier

2013-05-31 Thread Shriramana Sharma
On Fri, May 31, 2013 at 12:12 PM, Ali Çehreli acehr...@yahoo.com wrote: struct Pair { double x, y; } void main() { auto p0 = Pair(); auto p1 = Pair(1.5);// only p1.y is 0 Wouldn't p1.y actually be NaN and not 0? -- Shriramana Sharma ஶ்ரீரமணஶர்மா श्रीरमणशर्मा

Re: Automatic attribute inference of functions

2013-05-31 Thread Sebastian Graf
On Thursday, 30 May 2013 at 20:49:53 UTC, Steven Schveighoffer wrote: It's actually 4. separate compilation model. If you are building a module, and it imports a d interface file which has no function body, there is no conceivable way to tell what the attributes should be. For anonymous

Re: Using in as a parameter qualifier

2013-05-31 Thread bearophile
Shriramana Sharma: Wouldn't p1.y actually be NaN and not 0? Right. You can verify it with a writeln. Bye, bearophile

Re: and/or/not/xor operators

2013-05-31 Thread Regan Heath
On Fri, 31 May 2013 02:41:14 +0100, Shriramana Sharma samj...@gmail.com wrote: Thanks to all who replied. On Thu, May 30, 2013 at 10:18 PM, bearophile bearophileh...@lycos.com wrote: But Walter refused them time ago on the basis that no one uses them in C++. So you can ask for them in

Re: and/or/not/xor operators

2013-05-31 Thread Minas Mina
On Thursday, 30 May 2013 at 16:48:33 UTC, bearophile wrote: Shriramana Sharma: Hello. I have always loved the readability of C++'s and/or/not/xor word-like logical operators but It doesn't seem to be available in D. and/or/not are less visually noisy, they look better than the ugly /||/!

Re: double vs real

2013-05-31 Thread Timon Gehr
On 05/30/2013 06:45 PM, bearophile wrote: ... If you have to store many reals, they require more memory than doubles (how much is relative to the operating system). Regarding speed in theory double and real should give the same, ... If double uses xmm registers and real uses the fpu registers

Re: double vs real

2013-05-31 Thread Shriramana Sharma
On Fri, May 31, 2013 at 4:31 PM, Timon Gehr timon.g...@gmx.ch wrote: If double uses xmm registers and real uses the fpu registers (as is standard on x64), then double multiplication has twice the throughput of real multiplication on recent intel microarchitectures. Hi can you clarify that?

Producing library files from D

2013-05-31 Thread Shriramana Sharma
Hello. How do I make a library from D? I see the dmd --help output give a -lib option but am not sure how to actually use it. Can I produce a library and then just import it by its name? (This is an offshoot of my previous query about the proprietary lib thing.) And given that

Writing closed source programs in D?

2013-05-31 Thread Shriramana Sharma
Now I'm *not* going to write closed source programs in D [;-)], but am curious -- in C++ we have header files which a developer can confidently distribute along with the compiled libraries, and the actual source of the libraries (the *.cpp files) remains with the developer. In D, (obviously I'm a

Re: Writing closed source programs in D?

2013-05-31 Thread Regan Heath
On Fri, 31 May 2013 12:25:48 +0100, Shriramana Sharma samj...@gmail.com wrote: Now I'm *not* going to write closed source programs in D [;-)], but am curious -- in C++ we have header files which a developer can confidently distribute along with the compiled libraries, and the actual source of

Re: Producing library files from D

2013-05-31 Thread Regan Heath
On Fri, 31 May 2013 12:26:54 +0100, Shriramana Sharma samj...@gmail.com wrote: Hello. How do I make a library from D? I see the dmd --help output give a -lib option but am not sure how to actually use it. Can I produce a library and then just import it by its name? (This is an offshoot of my

alias this

2013-05-31 Thread Namespace
I thougth that in dmd 2.063 alias this : foo; would be allowed. That was what the preview of dmd 2.063 said: http://dlang.org/changelog.html#new2_062 Why wasn't it implemented?

Re: and/or/not/xor operators

2013-05-31 Thread bearophile
Regan Heath: I find them ugly and less clear - because I can glance at words symbols and immediately see the operator, faster than with words and symbols. Finding a short, common and easy to write English word ugly is quite strange, especially for a person that seems able to write in

Re: and/or/not/xor operators

2013-05-31 Thread Shriramana Sharma
On Fri, May 31, 2013 at 4:12 PM, Minas Mina minas_mina1...@hotmail.co.uk wrote: They are more noisy for non-English talking persons. Um and the rest of the D keywords are in what language?! -- Shriramana Sharma ஶ்ரீரமணஶர்மா श्रीरमणशर्मा

string literals

2013-05-31 Thread Jack Applegame
What's the reason that the string literal is a dynamic array, not a static? So sometimes it is not possible to get string length compile time: void foo(T: E[N], E, size_t N)(auto ref T data) { pragma(msg, static); pragma(msg, data.length); } void foo(T: E[], E)(auto ref T data) {

Re: and/or/not/xor operators

2013-05-31 Thread John Colvin
On Friday, 31 May 2013 at 10:21:19 UTC, Regan Heath wrote: Until this thread I didn't even know they existed.. Same. I use them every day in python, but I had no idea they were in C++ Tbh they annoy me in python, although that's just my C background showing.

Compiler bug? regression for the template function call syntax

2013-05-31 Thread rmc
Hi all, Not sure if this is a bug so thought I'd post here. It is very common to use a function template without the call () expecting that it will be called. However with the latest compilers hibernated only compiles when one leaves out the -property dmd command line option. The call:

Re: Passing large or complex data structures to threads

2013-05-31 Thread Joseph Rushton Wakeling
On 05/27/2013 02:08 PM, Joseph Rushton Wakeling wrote: On 05/26/2013 05:59 PM, Ali Çehreli wrote: On 05/26/2013 05:38 AM, Simen Kjaeraas wrote: Tuple!(size_t, size_t)[][] data = createData(); immutable dataImm = assumeUnique(data); data = null; // Simply to ensure no mutable

Re: Using in as a parameter qualifier

2013-05-31 Thread Jonathan M Davis
On Friday, May 31, 2013 15:10:01 Shriramana Sharma wrote: On Fri, May 31, 2013 at 12:12 PM, Ali Çehreli acehr...@yahoo.com wrote: Consider a function that operates on a pair: double abs2 ( pair a ) { return a.x * a.x + a.y * a.y ; } In C++ the function signature would be: double abs2 (

Re: Compiler bug? regression for the template function call syntax

2013-05-31 Thread Ali Çehreli
On 05/31/2013 07:32 AM, rmc wrote: It is very common to use a function template without the call () expecting that it will be called. Non-templated functions too. However with the latest compilers hibernated only compiles when one leaves out the -property dmd command line option. I think

Re: string literals

2013-05-31 Thread bearophile
Jack Applegame: What's the reason that the string literal is a dynamic array, not a static? Originally it was a fixed sized array. But in most cases you want a dynamic array. Rust language forces you to specify where to allocate the string literal with a symbol before the string, as

Re: Writing closed source programs in D?

2013-05-31 Thread Jonathan M Davis
On Friday, May 31, 2013 13:06:13 Regan Heath wrote: .di files are .d files without the function bodies etc. There are issues with templates and auto, but we will eventually have nice solutions for those. The only problem with auto is that the type can't be inferred without the function body.

Re: string literals

2013-05-31 Thread Jonathan M Davis
On Friday, May 31, 2013 16:20:44 Jack Applegame wrote: What's the reason that the string literal is a dynamic array, not a static? Would you really want to end up with a copy of a string literal every time you used it? The fact that they're immutable and can be passed around without ever

Re: Compiler bug? regression for the template function call syntax

2013-05-31 Thread Jonathan M Davis
On Friday, May 31, 2013 08:27:19 Ali Çehreli wrote: I think it is the same issue with non-templated functions. The best thing to do is to forget about the -property switch. I did about a year ago and never looked back. :) Given the most recent discussions on @property, I think that it's a

Re: Using in as a parameter qualifier

2013-05-31 Thread Ali Çehreli
On 05/31/2013 02:40 AM, Shriramana Sharma wrote: On Fri, May 31, 2013 at 12:12 PM, Ali Çehreli acehr...@yahoo.com wrote: double x,y ; this () {} That is not allowed. In D, every type has the .init property, which is its default value. Hm can you clarify that a bit? If I

Re: alias this

2013-05-31 Thread Ali Çehreli
On 05/31/2013 05:12 AM, Namespace wrote: I thougth that in dmd 2.063 alias this : foo; would be allowed. You mean the equal sign? alias this = foo; That was implemented in 2.061 by accident likely due to a confusion whether the new alias syntax should apply to 'alias this' as well.

Re: double vs real

2013-05-31 Thread Ali Çehreli
On 05/31/2013 04:28 AM, Shriramana Sharma wrote: On Fri, May 31, 2013 at 4:31 PM, Timon Gehr timon.g...@gmx.ch wrote: If double uses xmm registers and real uses the fpu registers (as is standard on x64), then double multiplication has twice the throughput of real multiplication on recent

Are heap objects never moved by the garbage collector?

2013-05-31 Thread Carl Sturtivant
The D Programming Language (TDPL) p.178 asserts the following. The objects themselves stay put, that is their locations in memory never change after creation. I take this to mean that the D garbage collector doesn't move live objects and adjust all references to them the way that some

Re: alias this

2013-05-31 Thread Namespace
No, I meant the colon. alias this : foo;

Re: string literals

2013-05-31 Thread Jack Applegame
On Friday, 31 May 2013 at 15:35:51 UTC, Jonathan M Davis wrote: The fact that it's a string is irrelevant, and making it a static array woludn't help any. If data were a template argument, it would work, but it's a funciton argument, so it won't. If to pass reference to static array as

Re: alias this

2013-05-31 Thread Simen Kjaeraas
On 2013-05-31, 14:12, Namespace wrote: I thougth that in dmd 2.063 alias this : foo; would be allowed. That was what the preview of dmd 2.063 said: http://dlang.org/changelog.html#new2_062 Why wasn't it implemented? Probably not enough time. I've not read anything about it no longer being

Re: Are heap objects never moved by the garbage collector?

2013-05-31 Thread Simen Kjaeraas
On 2013-05-31, 18:31, Carl Sturtivant wrote: The D Programming Language (TDPL) p.178 asserts the following. The objects themselves stay put, that is their locations in memory never change after creation. I take this to mean that the D garbage collector doesn't move live objects and

Segfault on simple program?

2013-05-31 Thread Shriramana Sharma
import std.stdio ; void foo ( int[] array ) { foreach ( i ; array ) { writeln ( i ) ; } } void main () { foo ( [ 1, 2, 3 ] ) ; } On both DMD 2.062 and 2.063 this compiles OK but causes a segfault. I'm running Kubuntu Raring 64-bit. Any hints? -- Shriramana Sharma ஶ்ரீரமணஶர்மா

Re: Are heap objects never moved by the garbage collector?

2013-05-31 Thread bearophile
Carl Sturtivant: Does D guarantee this? In theory D is designed to allow a moving garbage collector. The current GC doesn't move objects. Bye, bearophile

Re: Exception isn't thrown as expected

2013-05-31 Thread Marco Leise
Am Fri, 31 May 2013 10:59:09 +0700 schrieb Alexandr Druzhinin drug2...@bk.ru: You mean I didn't initialize c? It was a wild guess, that you might come from C++ and write SomeClass c; which would be an instance of that class in C++, but a null reference in D. As you said you only get the

Re: Using in as a parameter qualifier

2013-05-31 Thread Shriramana Sharma
Thanks to all who explained the various issues. Some more questions: On Fri, May 31, 2013 at 9:28 PM, Ali Çehreli acehr...@yahoo.com wrote: What the error message is saying is that you can declare it just to disable its use: struct Pair { double x = 10.75; double y = 20.25; //

Re: Segfault on simple program?

2013-05-31 Thread John Colvin
On Friday, 31 May 2013 at 17:14:46 UTC, Shriramana Sharma wrote: import std.stdio ; void foo ( int[] array ) { foreach ( i ; array ) { writeln ( i ) ; } } void main () { foo ( [ 1, 2, 3 ] ) ; } On both DMD 2.062 and 2.063 this compiles OK but causes a segfault. I'm running

Re: Using in as a parameter qualifier

2013-05-31 Thread Ali Çehreli
On 05/31/2013 10:49 AM, Shriramana Sharma wrote: struct Pair { double x = 10.75; double y = 20.25; // Default constructor disabled @disable this(); // Users must use another constructor: this(double x, double y) { this.x = x; this.y = y; } } As you see,

Re: Segfault on simple program?

2013-05-31 Thread John Colvin
On Friday, 31 May 2013 at 18:22:44 UTC, Shriramana Sharma wrote: On Fri, May 31, 2013 at 11:46 PM, John Colvin john.loughran.col...@gmail.com wrote: Can't reproduce this. Any chance of a stacktrace and/or disassembly? Please give instructions as to how I can get either of those two for

Re: Are heap objects never moved by the garbage collector?

2013-05-31 Thread Diggory
On Friday, 31 May 2013 at 17:14:52 UTC, Jonathan M Davis wrote: On Friday, May 31, 2013 18:31:38 Carl Sturtivant wrote: The D Programming Language (TDPL) p.178 asserts the following. The objects themselves stay put, that is their locations in memory never change after creation. I take this

Re: double vs real

2013-05-31 Thread John Colvin
On Friday, 31 May 2013 at 16:17:28 UTC, Ali Çehreli wrote: On 05/31/2013 04:28 AM, Shriramana Sharma wrote: On Fri, May 31, 2013 at 4:31 PM, Timon Gehr timon.g...@gmx.ch wrote: If double uses xmm registers and real uses the fpu registers (as is standard on x64), then double multiplication

Re: and/or/not/xor operators

2013-05-31 Thread ixid
We really don't want D to become a TMTOWTDI language. Ideally there should be 1 right way and no alternatives. That way, anyone who knows D will have a greater chance of knowing what any given code sample does, and not have to look up alternate syntax etc. R Up to a point I'd certainly

how to use shared keyword in 2.063 version?

2013-05-31 Thread Andrey
Hello! I'm trying to use following code: == //... class A { private { int m_someVar = 10; } public { this() { } } } int main(string[] args) {

Re: Using in as a parameter qualifier

2013-05-31 Thread Jesse Phillips
On Friday, 31 May 2013 at 17:50:33 UTC, Shriramana Sharma wrote: Sorry but I still don't get it -- if a default constructor is disallowed for struct-s by the language itself, why should I have to *tell* the compiler to disable it? The compiler always provides a default constructor (maybe not

Re: how to use shared keyword in 2.063 version?

2013-05-31 Thread Anthony Goins
On Friday, 31 May 2013 at 21:01:49 UTC, Andrey wrote: Hello! I'm trying to use following code: == //... class A { private { int m_someVar = 10; } public { this() {

Re: double vs real

2013-05-31 Thread Timon Gehr
On 05/31/2013 09:08 PM, John Colvin wrote: On Friday, 31 May 2013 at 16:17:28 UTC, Ali Çehreli wrote: On 05/31/2013 04:28 AM, Shriramana Sharma wrote: On Fri, May 31, 2013 at 4:31 PM, Timon Gehr timon.g...@gmx.ch wrote: If double uses xmm registers and real uses the fpu registers (as is

Re: double vs real

2013-05-31 Thread Timon Gehr
On 05/31/2013 01:28 PM, Shriramana Sharma wrote: On Fri, May 31, 2013 at 4:31 PM, Timon Gehr timon.g...@gmx.ch wrote: If double uses xmm registers and real uses the fpu registers (as is standard on x64), then double multiplication has twice the throughput of real multiplication on recent intel

Re: Using in as a parameter qualifier

2013-05-31 Thread Jonathan M Davis
On Friday, May 31, 2013 23:25:02 Jesse Phillips wrote: On Friday, 31 May 2013 at 17:50:33 UTC, Shriramana Sharma wrote: Sorry but I still don't get it -- if a default constructor is disallowed for struct-s by the language itself, why should I have to *tell* the compiler to disable it?

Re: Using in as a parameter qualifier

2013-05-31 Thread Shriramana Sharma
On Sat, Jun 1, 2013 at 1:13 AM, Jonathan M Davis jmdavisp...@gmx.com wrote: Certainly, for anything that's small enough to fit in a register, it's likely to be faster to pass by value. So pardon my ignorance, but a pair which only contains two doubles -- it would fit in a CPU register? How

Re: Using in as a parameter qualifier

2013-05-31 Thread Shriramana Sharma
On Fri, May 31, 2013 at 8:55 PM, Jonathan M Davis jmdavisp...@gmx.com wrote: In D, const ref does not accept rvalues (unlike C++'s const ). So what is the syntax that accepts rvalues and yet does not make a copy of the input object? I mean, as Ali says OK profiling is preferable to find out

Re: Segfault on simple program?

2013-05-31 Thread Shriramana Sharma
On Sat, Jun 1, 2013 at 12:07 AM, John Colvin john.loughran.col...@gmail.com wrote: given a program named test in the current directory gdb ./test run #will segfault bt full and copy the output. Did it (after installing libc6-dbg just in case) but it doesn't seem to be very

Re: Using in as a parameter qualifier

2013-05-31 Thread Shriramana Sharma
On Sat, Jun 1, 2013 at 5:11 AM, Shriramana Sharma samj...@gmail.com wrote: So what is the syntax that accepts rvalues and yet does not make a copy of the input object? I mean, as Ali says OK profiling is preferable to find out where exactly passing by value is more efficient than passing by

Re: Segfault on simple program?

2013-05-31 Thread Anthony Goins
On Friday, 31 May 2013 at 17:14:46 UTC, Shriramana Sharma wrote: import std.stdio ; void foo ( int[] array ) { foreach ( i ; array ) { writeln ( i ) ; } } void main () { foo ( [ 1, 2, 3 ] ) ; } On both DMD 2.062 and 2.063 this compiles OK but causes a segfault. I'm running

Re: how to use shared keyword in 2.063 version?

2013-05-31 Thread Jonathan M Davis
On Friday, May 31, 2013 23:26:19 Anthony Goins wrote: To create a shared object you need shared this ctor. immutable this() for immutable, and const this() for const. Check out the change log. #2 on the list. Either that or you create it as thread-local and cast to shared. - Jonathan M

removing ansi control escape characters from a string

2013-05-31 Thread Timothee Cour
Not sure this is the right forum but here we go: When using unix command 'script' to log the terminal input/output commands, it includes special ansi control escape characters. I'd like to filter out the generated script file from those character sequences, so that it preserves the content

Re: Segfault on simple program?

2013-05-31 Thread Shriramana Sharma
On Sat, Jun 1, 2013 at 6:02 AM, Anthony Goins neonto...@gmail.com wrote: Works for me ubuntu 64. Do you have both versions installed? Of course not. The later install from the distributed DEB (from dlang.org) overwrites the earlier one by apt install. Would it compile if you used the wrong

Re: Using in as a parameter qualifier

2013-05-31 Thread Ali Çehreli
On 05/31/2013 04:41 PM, Shriramana Sharma wrote: On Fri, May 31, 2013 at 8:55 PM, Jonathan M Davis jmdavisp...@gmx.com wrote: In D, const ref does not accept rvalues (unlike C++'s const ). So what is the syntax that accepts rvalues and yet does not make a copy of the input object? I

Re: Using in as a parameter qualifier

2013-05-31 Thread Jonathan M Davis
On Saturday, June 01, 2013 05:11:44 Shriramana Sharma wrote: On Fri, May 31, 2013 at 8:55 PM, Jonathan M Davis jmdavisp...@gmx.com wrote: In D, const ref does not accept rvalues (unlike C++'s const ). So what is the syntax that accepts rvalues and yet does not make a copy of the input

Re: Using in as a parameter qualifier

2013-05-31 Thread Jonathan M Davis
On Saturday, June 01, 2013 04:39:07 Shriramana Sharma wrote: On Sat, Jun 1, 2013 at 1:13 AM, Jonathan M Davis jmdavisp...@gmx.com wrote: Certainly, for anything that's small enough to fit in a register, it's likely to be faster to pass by value. So pardon my ignorance, but a pair which

Re: Using in as a parameter qualifier

2013-05-31 Thread Jonathan M Davis
On Saturday, June 01, 2013 05:15:22 Shriramana Sharma wrote: On Sat, Jun 1, 2013 at 5:11 AM, Shriramana Sharma samj...@gmail.com wrote: So what is the syntax that accepts rvalues and yet does not make a copy of the input object? I mean, as Ali says OK profiling is preferable to find out

Re: Using in as a parameter qualifier

2013-05-31 Thread Ali Çehreli
On 05/31/2013 04:45 PM, Shriramana Sharma wrote: And again, sorry if I'm being dumb, but is the proposed inout syntax intended to fix this problem or some other problem? Think of 'inout' as a placeholder for one of the following three: - const - immutable - (no const, nor immutable) inout

Re: removing ansi control escape characters from a string

2013-05-31 Thread Adam D. Ruppe
On Saturday, 1 June 2013 at 01:08:46 UTC, Timothee Cour wrote: removes escape codes for coloring, etc. Getting all these is a very difficult task because the escape sequences aren't all well defined. But, you should get pretty good results by just filtering out anything that starts with

Re: removing ansi control escape characters from a string

2013-05-31 Thread Adam D. Ruppe
On Saturday, 1 June 2013 at 01:08:46 UTC, Timothee Cour wrote: string; also the behavior of backspace needs to be emulated. oops I missed this on my fires readthrough. But if instead of if(c == 8) continue, you did if(c == 8){ outputString = outputString[0 .. $-1]; continue;} that should be

Re: Using in as a parameter qualifier

2013-05-31 Thread Shriramana Sharma
Thanks Jonathan and Ali for all those clarifications. -- Shriramana Sharma ஶ்ரீரமணஶர்மா श्रीरमणशर्मा