Re: shouldn't this code at least trigger a warning?

2015-04-29 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 29 April 2015 at 06:37:44 UTC, ketmar wrote: subj. the code: void main () { import std.stdio; char ch = '!'; switch (ch) { int n = 42; case '!': writeln(n, : wow!); break; default: } } i think that such abomination should: 1. be forbidden,

Re: Runtime metaprogramming in D

2015-04-29 Thread Dennis Ritchie via Digitalmars-d-learn
On Wednesday, 29 April 2015 at 02:20:25 UTC, Vladimir Panteleev wrote: On Wednesday, 29 April 2015 at 01:38:17 UTC, Dennis Ritchie wrote: Hi, Is it possible to write self-modifying code in D, who will perform at runtime? Not easily. Just the obvious approach to invoke the compiler and

Re: shouldn't this code at least trigger a warning?

2015-04-29 Thread via Digitalmars-d-learn
On Wednesday, 29 April 2015 at 06:37:44 UTC, ketmar wrote: subj. the code: void main () { import std.stdio; char ch = '!'; switch (ch) { int n = 42; case '!': writeln(n, : wow!); break; default: } } i think that such abomination should: 1. be forbidden,

shouldn't this code at least trigger a warning?

2015-04-29 Thread ketmar via Digitalmars-d-learn
subj. the code: void main () { import std.stdio; char ch = '!'; switch (ch) { int n = 42; case '!': writeln(n, : wow!); break; default: } } i think that such abomination should: 1. be forbidden, or 2. trigger a warning, or 3. execute initializer anyway.

Re: [dvm] Can't install compilers on Mac

2015-04-29 Thread Jacob Carlborg via Digitalmars-d-learn
On 2015-04-28 19:46, Chris wrote: I keep getting this message. Why? Fetching: http://ftp.digitalmars.com/dmd.2.067.0.zip [] 56256/54884 KB Installing: dmd-2.067.0 An unknown error occurred:

Re: shouldn't this code at least trigger a warning?

2015-04-29 Thread Ali Çehreli via Digitalmars-d-learn
On 04/29/2015 07:57 AM, H. S. Teoh via Digitalmars-d-learn wrote: Switch statements in D allow all sorts of abominations, if only you would try it. I think it was originally designed to support a particular loop idiom (sorry I forgot what it was called

ldc std.getopt

2015-04-29 Thread Laeeth Isharc via Digitalmars-d-learn
When building the following (reduced by hand - I hope I didn't take out something useful when doing so): import std.stdio; import std.getopt; int main(string[] args) { string apiKey; string startCode; bool reverseOrder=false; bool noReverse=false; auto

Re: Runtime metaprogramming in D

2015-04-29 Thread Ali Çehreli via Digitalmars-d-learn
On 04/28/2015 07:20 PM, Vladimir Panteleev wrote: On Wednesday, 29 April 2015 at 01:38:17 UTC, Dennis Ritchie wrote: Hi, Is it possible to write self-modifying code in D, who will perform at runtime? Not easily. Just the obvious approach to invoke the compiler and run/load the created

Re: Runtime metaprogramming in D

2015-04-29 Thread Dennis Ritchie via Digitalmars-d-learn
On Wednesday, 29 April 2015 at 17:35:50 UTC, Ali Çehreli wrote: SDC will make D such a language. :) Ali It remains to build SDC in the standard library of the future DDMD :)

Re: Create custom data types

2015-04-29 Thread tcak via Digitalmars-d-learn
On Wednesday, 29 April 2015 at 17:17:07 UTC, Dennis Ritchie wrote: Hi, Is it possible to create simple D user-defined data types without the use of classes and other OOP? For example, in Ada is done as follows: - type balance is new Integer range -32_000 .. 32_000; I think you can use

Re: Create custom data types

2015-04-29 Thread Ali Çehreli via Digitalmars-d-learn
On 04/29/2015 10:17 AM, Dennis Ritchie wrote: Hi, Is it possible to create simple D user-defined data types without the use of classes and other OOP? For example, in Ada is done as follows: - type balance is new Integer range -32_000 .. 32_000; Something similar to the following solution

Re: Create a case-insensitive startsWith

2015-04-29 Thread PhilipDaniels via Digitalmars-d-learn
On Tuesday, 28 April 2015 at 22:34:07 UTC, Justin Whear wrote: if (startsWith!icmp(a, b) == 0(input, 0x)) if (startsWith!std.uni.icmp(a, b) == 0(input, 0x)) if (startsWith!((a,b) = icmp(a,b) == 0)(input, 0x)) The issue is that those icmp functions take strings as arguments while

Re: Create custom data types

2015-04-29 Thread Dennis Ritchie via Digitalmars-d-learn
On Wednesday, 29 April 2015 at 17:52:27 UTC, Ali Çehreli wrote: On 04/29/2015 10:17 AM, Dennis Ritchie wrote: Hi, Is it possible to create simple D user-defined data types without the use of classes and other OOP? For example, in Ada is done as follows: - type balance is new Integer

Create custom data types

2015-04-29 Thread Dennis Ritchie via Digitalmars-d-learn
Hi, Is it possible to create simple D user-defined data types without the use of classes and other OOP? For example, in Ada is done as follows: - type balance is new Integer range -32_000 .. 32_000;

Re: C++ interface problem

2015-04-29 Thread extrawurst via Digitalmars-d-learn
On Wednesday, 29 April 2015 at 13:55:46 UTC, Benjamin Thaut wrote: On Monday, 27 April 2015 at 21:19:02 UTC, extrawurst wrote: here is the shortened version of the returned class CSteamID: https://gist.github.com/Extrawurst/936f56ceaa87cf287257 this is the shortened interface (no destructors

stdx.data.json

2015-04-29 Thread Laeeth Isharc via Digitalmars-d-learn
Hi. What's the best way to pass the contents of a file to the stream parser without reading the whole thing into memory first? I get an error if using byLine because the kind of range this function returns is not what the stream parser is expecting. There is an optional filename argument

Re: ldc std.getopt

2015-04-29 Thread Anon via Digitalmars-d-learn
On Wednesday, 29 April 2015 at 19:43:44 UTC, Laeeth Isharc wrote: I get the following errors under LDC (this is LDC beta, but same problem under master) although the code compiles fine under DMD. Am I doing something wrong? The help generating feature of std.getopt is new in 2.067. Use

Re: Create custom data types

2015-04-29 Thread Ali Çehreli via Digitalmars-d-learn
On 04/29/2015 12:53 PM, Dennis Ritchie wrote: On Wednesday, 29 April 2015 at 17:52:27 UTC, Ali Çehreli wrote: It should be easy to make a template of it. (I really think it should already be in Phobos. :) ) Where can I find documentation on this subject? Once a piece of code works for a

String from executeshell

2015-04-29 Thread William Dunne via Digitalmars-d-learn
I'm trying to run this command: wget -O - URL | gpg -d and get the result of the action, but I can't quite work out to do it. currently it looks like: executeShell(escapeShellCommand(wget, -O, -, url, |, gpg, -D)); But I can't work out how to pull the string returned with this. Any help?

Re: [dvm] Can't install compilers on Mac

2015-04-29 Thread Chris via Digitalmars-d-learn
On Wednesday, 29 April 2015 at 06:41:30 UTC, Jacob Carlborg wrote: On 2015-04-28 19:46, Chris wrote: I keep getting this message. Why? Fetching: http://ftp.digitalmars.com/dmd.2.067.0.zip [] 56256/54884 KB Installing: dmd-2.067.0 An unknown error

Re: Possible to write a classic fizzbuzz example using a UFCS chain?

2015-04-29 Thread Atila Neves via Digitalmars-d-learn
On Tuesday, 28 April 2015 at 10:46:54 UTC, Gary Willoughby wrote: After reading the following thread: http://forum.dlang.org/thread/nczgumcdfystcjqyb...@forum.dlang.org I wondered if it was possible to write a classic fizzbuzz[1] example using a UFCS chain? I've tried and failed. [1]:

Re: String from executeshell

2015-04-29 Thread Ali Çehreli via Digitalmars-d-learn
On 04/29/2015 02:05 PM, William Dunne wrote: I'm trying to run this command: wget -O - URL | gpg -d and get the result of the action, but I can't quite work out to do it. currently it looks like: executeShell(escapeShellCommand(wget, -O, -, url, |, gpg, -D)); But I can't work out how to pull

Re: String from executeshell

2015-04-29 Thread Ali Çehreli via Digitalmars-d-learn
On 04/29/2015 02:54 PM, Ali Çehreli wrote: executeShell returns the status and the output as a type Certainly not. The output is an object of a special type, which the documentation refers to as 'auto'. Grrr... :) Ok, maybe it's a Voldemort type. Anyway... Ali

Re: Create custom data types

2015-04-29 Thread Dennis Ritchie via Digitalmars-d-learn
On Wednesday, 29 April 2015 at 21:49:08 UTC, Ali Çehreli wrote: On 04/29/2015 12:53 PM, Dennis Ritchie wrote: On Wednesday, 29 April 2015 at 17:52:27 UTC, Ali Çehreli wrote: It should be easy to make a template of it. (I really think it should already be in Phobos. :) ) Where can I find

Re: Create a case-insensitive startsWith

2015-04-29 Thread Robert burner Schadek via Digitalmars-d-learn
if(0X.std.string.indexOf(0x, CaseSensitive.no) == 0) should work

Re: Create custom data types

2015-04-29 Thread Ali Çehreli via Digitalmars-d-learn
On 04/29/2015 03:48 PM, Dennis Ritchie wrote: Thanks. And how can I stop all attempts to perform actions arifmiticheskih the type int? Ie action to t += b; suppressed to compile. Some operator overloading is needed. I am pretty sure someone must have implemented such a type. What I add below

Re: String from executeshell

2015-04-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 29 April 2015 at 21:56:18 UTC, Ali Çehreli wrote: Certainly not. The output is an object of a special type, which the documentation refers to as 'auto'. Grrr... :) Ok, maybe it's a Voldemort type. Anyway... That's idiotic, to be frank, it should just be a traditional struct

getopt helpWanted

2015-04-29 Thread novice2 via Digitalmars-d-learn
Hello. Help me please to understand, how to show usage help to user, who enter wrong options? For example, user not provided required filename. I want to show error message, and program usage help text. But likely getopt don't provide help text until valid options will be parsed. Reduced

Re: getopt helpWanted

2015-04-29 Thread Brian Schott via Digitalmars-d-learn
What you're trying to do is currently impossible. I filed a bug (https://issues.dlang.org/show_bug.cgi?id=14525) because what you're trying to do really should be possible. import std.stdio : writefln; import std.getopt; void main(string[] args) { string fname; try {

Re: Create custom data types

2015-04-29 Thread Dennis Ritchie via Digitalmars-d-learn
On Wednesday, 29 April 2015 at 23:22:43 UTC, Ali Çehreli wrote: On 04/29/2015 04:16 PM, Ali Çehreli wrote: ref CustomInteger opOpAssign(string op, T2)(T2 rhs) { static if (is (T2 == CustomInteger)) { mixin(value_ ~ op ~ = rhs.value_;); return this;

Re: ldc std.getopt

2015-04-29 Thread Laeeth Isharc via Digitalmars-d-learn
On Wednesday, 29 April 2015 at 20:45:26 UTC, Anon wrote: On Wednesday, 29 April 2015 at 19:43:44 UTC, Laeeth Isharc wrote: I get the following errors under LDC (this is LDC beta, but same problem under master) although the code compiles fine under DMD. Am I doing something wrong? The help

Re: Create custom data types

2015-04-29 Thread Ali Çehreli via Digitalmars-d-learn
On 04/29/2015 04:16 PM, Ali Çehreli wrote: ref CustomInteger opOpAssign(string op, T2)(T2 rhs) { static if (is (T2 == CustomInteger)) { mixin(value_ ~ op ~ = rhs.value_;); return this; } else { return this.opOpAssign!(op,

Re: Reducing source code: weak+alias values in array

2015-04-29 Thread Artur Skawina via Digitalmars-d-learn
On 04/27/15 19:49, Jens Bauer via Digitalmars-d-learn wrote: I was wondering if there's a way to reduce my bulky startup files a bit. If using the GNU Assembler (GAS), then one can reduce the code using a macro like this: /* The EXC macro makes a weak+alias for the * symbol 'value',

Re: C++ interface problem

2015-04-29 Thread Benjamin Thaut via Digitalmars-d-learn
On Monday, 27 April 2015 at 21:19:02 UTC, extrawurst wrote: here is the shortened version of the returned class CSteamID: https://gist.github.com/Extrawurst/936f56ceaa87cf287257 this is the shortened interface (no destructors in the rest of the code either):

Re: Fuzzy Levenshtein variant of std.conv.to

2015-04-29 Thread via Digitalmars-d-learn
On Tuesday, 28 April 2015 at 23:09:27 UTC, Per Nordlöw wrote: On Tuesday, 28 April 2015 at 16:20:24 UTC, Per Nordlöw wrote: I update my Github repo. I had forgotten to push my latest changes. I solved it.

Re: String from executeshell

2015-04-29 Thread Vladimir Panteleev via Digitalmars-d-learn
On Wednesday, 29 April 2015 at 21:56:18 UTC, Ali Çehreli wrote: On 04/29/2015 02:54 PM, Ali Çehreli wrote: executeShell returns the status and the output as a type Certainly not. The output is an object of a special type, which the documentation refers to as 'auto'. Grrr... :) Ok, maybe

dub building is extremely slow

2015-04-29 Thread zhmt via Digitalmars-d-learn
dub build is running on centos7. It works well until today, It becomes very slow suddenly. It will take minuties per compilation, there is 10 files in project. Has anyone experienced this?

Re: dub building is extremely slow

2015-04-29 Thread zhmt via Digitalmars-d-learn
On Thursday, 30 April 2015 at 02:02:50 UTC, zhmt wrote: dub build is running on centos7. It works well until today, It becomes very slow suddenly. It will take minuties per compilation, there is 10 files in project. Has anyone experienced this? It is because: The dub will connect to some

Re: shouldn't this code at least trigger a warning?

2015-04-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/29/15 5:25 AM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: On Wednesday, 29 April 2015 at 06:37:44 UTC, ketmar wrote: subj. the code: void main () { import std.stdio; char ch = '!'; switch (ch) { int n = 42; case '!': writeln(n, : wow!); break;

Re: Fuzzy Levenshtein variant of std.conv.to

2015-04-29 Thread Jakob Ovrum via Digitalmars-d-learn
On Wednesday, 29 April 2015 at 14:46:04 UTC, Per Nordlöw wrote: On Tuesday, 28 April 2015 at 23:09:27 UTC, Per Nordlöw wrote: On Tuesday, 28 April 2015 at 16:20:24 UTC, Per Nordlöw wrote: I update my Github repo. I had forgotten to push my latest changes. I solved it. I started working on

Re: Create custom data types

2015-04-29 Thread Ali Çehreli via Digitalmars-d-learn
On 04/29/2015 04:30 PM, Dennis Ritchie wrote: On Wednesday, 29 April 2015 at 23:22:43 UTC, Ali Çehreli wrote: On 04/29/2015 04:16 PM, Ali Çehreli wrote: ref CustomInteger opOpAssign(string op, T2)(T2 rhs) { static if (is (T2 == CustomInteger)) { mixin(value_ ~

Re: shouldn't this code at least trigger a warning?

2015-04-29 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Apr 29, 2015 at 06:37:44AM +, ketmar via Digitalmars-d-learn wrote: subj. the code: void main () { import std.stdio; char ch = '!'; switch (ch) { int n = 42; case '!': writeln(n, : wow!); break; default: } } i think that such

Re: Reducing source code: weak+alias values in array

2015-04-29 Thread Jens Bauer via Digitalmars-d-learn
On Wednesday, 29 April 2015 at 13:58:14 UTC, Artur Skawina wrote: On 04/27/15 19:49, Jens Bauer via Digitalmars-d-learn wrote: I was wondering if there's a way to reduce my bulky startup files a bit. If using the GNU Assembler (GAS), then one can reduce the code using a macro like this: