Re: Multithreading in D

2014-10-08 Thread AsmMan via Digitalmars-d-learn
What I imagine as solution (I know it won't work this way, but to give you a better idea): for(int i = 0; i #threads; i++){ runInThread(generateTerrain(...)); } Are you looking for parallel? http://dlang.org/library/std/parallelism/parallel.html

Re: 'write' crashes without extra window

2014-10-07 Thread AsmMan via Digitalmars-d-learn
On Tuesday, 7 October 2014 at 23:41:14 UTC, Joel wrote: I have a program that runs at Windows 7 login, each time. But it had been opening with a command prompt, so I got rid of the prompt and now it some times crashes. I've noticed it before, using 'write' without the prompt. Can you post

coding practices: include whole module or only the needed function

2014-10-06 Thread AsmMan via Digitalmars-d-learn
Which practice do you use: if you need only one or two functions from a module: import myModule : func, func2; or (import whole module, assuming no function name conflits of course) import myModule; any words why one over the other are welcome. I like the first one why it explicitly show

How do I check if a function got CTFE?

2014-10-02 Thread AsmMan via Digitalmars-d-learn
I'd like to check if a function got CTFE, ie, the compiler was able to replace my foo(s); by the computed value at compile-time. I'm trying to convert the binary executable to assembly by using objconv tool but I'm finding it very diffucult to find anything in there, since some converters

Re: How do I check if a function got CTFE?

2014-10-02 Thread AsmMan via Digitalmars-d-learn
On Thursday, 2 October 2014 at 18:02:30 UTC, Adam D. Ruppe wrote: On Thursday, 2 October 2014 at 17:56:29 UTC, AsmMan wrote: I'd like to check if a function got CTFE, ie, the compiler was able to replace my foo(s); by the computed value at compile-time. You have to explicitly force ctfe with

Re: How do I check if a function got CTFE?

2014-10-02 Thread AsmMan via Digitalmars-d-learn
On Thursday, 2 October 2014 at 18:17:12 UTC, anonymous wrote: On Thursday, 2 October 2014 at 17:56:29 UTC, AsmMan wrote: I'd like to check if a function got CTFE, ie, the compiler was able to replace my foo(s); by the computed value at compile-time. I'm trying to convert the binary

out parameter with default value

2014-09-29 Thread AsmMan via Digitalmars-d-learn
Why it does works: void f(out int c) { if(some_cond) c = 10; } but it doesn't? void f(out int c = 1) { if(some_cond) c = 10; } it give compiler error: Error: constant 1 is not an lvalue

Re: out parameter with default value

2014-09-29 Thread AsmMan via Digitalmars-d-learn
My question is why it doesn't works and if there's a workaround

Re: out parameter with default value

2014-09-29 Thread AsmMan via Digitalmars-d-learn
I had just forget out and ref are same as pointers... thanks guys

Re: Can I make a variable public and readonly (outside where was declared) at same time?

2014-09-27 Thread AsmMan via Digitalmars-d-learn
On Friday, 26 September 2014 at 18:18:45 UTC, Steven Schveighoffer wrote: On 9/26/14 1:36 PM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: Alternatively, you could create a union with a private and a public member with the same types, but I wouldn't recommend it. Besides, the

Can I get caller name?

2014-09-26 Thread AsmMan via Digitalmars-d-learn
for debugging purposes, I need to get the caller name. Is it possible? if so, how do I do this? void foo() { baa(); } void baa() { wrilten(caller_name()); // foo } I know I could create an extra parameter and pass the current function name as argument but it isn't a possibility for now.

Re: Can I get caller name?

2014-09-26 Thread AsmMan via Digitalmars-d-learn
Thanks guys!

Can I make a variable public and readonly (outside where was declared) at same time?

2014-09-26 Thread AsmMan via Digitalmars-d-learn
I know I can combine it by making an extra variable plus a property like this: class Foo { private int a_; void do_something1() { a_ = baa(); } void do_something2() { if(cond) a_ = baa2(); } @property int a() { return a; } } This is the C#'s to do which

Re: Does D has C#'s string.Empty?

2014-09-25 Thread AsmMan via Digitalmars-d-learn
On Thursday, 25 September 2014 at 06:41:03 UTC, SlomoTheBrave wrote: On Thursday, 25 September 2014 at 05:29:37 UTC, AsmMan wrote: Does D has C#'s string.Empty? string.init ? string a; a = string.init; assert( a == ); does the job for the type string at least.

Re: Does D has C#'s string.Empty?

2014-09-25 Thread AsmMan via Digitalmars-d-learn
On Thursday, 25 September 2014 at 12:43:57 UTC, Steven Schveighoffer wrote: On 9/25/14 2:41 AM, SlomoTheBrave wrote: On Thursday, 25 September 2014 at 05:29:37 UTC, AsmMan wrote: Does D has C#'s string.Empty? string.init ? string a; a = string.init; assert( a == );

Re: Does D has C#'s string.Empty?

2014-09-25 Thread AsmMan via Digitalmars-d-learn
On Friday, 26 September 2014 at 00:53:24 UTC, ketmar via Digitalmars-d-learn wrote: On Fri, 26 Sep 2014 00:24:27 + AsmMan via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: It made me a bit confusing. How is the implementation of string comparasion in D? has length of 0

Does D has C#'s string.Empty?

2014-09-24 Thread AsmMan via Digitalmars-d-learn
Does D has C#'s string.Empty?

Re: Does remove immutability using cast to pass in a function make sense?

2014-09-23 Thread AsmMan via Digitalmars-d-learn
On Tuesday, 23 September 2014 at 03:34:22 UTC, Ali Çehreli wrote: If it still doesn't work for you please show us a minimal program that demonstrates the problem. Ali Ok, the case is the follow, I updated my dmd compiler some days ago (after my mono crashed and I lost some of D files, I

Does remove immutability using cast to pass in a function make sense?

2014-09-22 Thread AsmMan via Digitalmars-d-learn
I have this array: static immutable string[] months = [jan, fev, ...]; I need to pass it into canFind(). But it doesn't works with immutables so I need to cast it like in canFind(cast(string[]) months, month) to work. There's a reason related to design why it doesn't work with immutables or

put string[] into a appender without loop?

2014-09-21 Thread AsmMan via Digitalmars-d-learn
I'd like to copy an array string into a appender!string() but I can't see how to do this without loop myself over the string array. Is there a native function or should I write it myself?

Re: put string[] into a appender without loop?

2014-09-21 Thread AsmMan via Digitalmars-d-learn
On Sunday, 21 September 2014 at 23:41:58 UTC, AsmMan wrote: I'd like to copy an array string into a appender!string() but I can't see how to do this without loop myself over the string array. Is there a native function or should I write it myself? call: auto app = appender!string();

Re: put string[] into a appender without loop?

2014-09-21 Thread AsmMan via Digitalmars-d-learn
On Monday, 22 September 2014 at 00:09:22 UTC, Vladimir Panteleev wrote: On Sunday, 21 September 2014 at 23:48:59 UTC, AsmMan wrote: On Sunday, 21 September 2014 at 23:41:58 UTC, AsmMan wrote: I'd like to copy an array string into a appender!string() but I can't see how to do this without loop

Re: put string[] into a appender without loop?

2014-09-21 Thread AsmMan via Digitalmars-d-learn
On Monday, 22 September 2014 at 00:30:44 UTC, Vladimir Panteleev wrote: On Monday, 22 September 2014 at 00:18:03 UTC, AsmMan wrote: this give undefined identifier: 'put' error. (std.array is already included, buffer.put(string) doesn't give same error) You need to import std.range. Thanks,

Re: pop popFront combined

2014-09-20 Thread AsmMan via Digitalmars-d-learn
On Saturday, 20 September 2014 at 18:59:03 UTC, Nordlöw wrote: Is there a reason why popFront doesn't automatically return what front does? If so I'm still missing a combined variant of pop and popFront in std.range. Why isn't such a common operation in Phobos already? So far I know isn't

Re: regex problems

2014-09-20 Thread AsmMan via Digitalmars-d-learn
On Saturday, 20 September 2014 at 15:28:54 UTC, seany wrote: consider this: import std.conv, std.algorithm; import core.vararg; import std.stdio, std.regex; void main() { string haystack = ID : generateWorld; Position : {

Re: std.utf.decode(dlang, 1)

2014-09-18 Thread AsmMan via Digitalmars-d-learn
On Thursday, 18 September 2014 at 06:09:54 UTC, Algo wrote: void main() { import std.utf; decode(dlang, 1); } Error: template std.utf.decode cannot deduce function from argument types !()(string, int), candidates are: D:\msc\D\dmd2\windows\bin\..\..\src\phobos\std\utf.d(924):

Re: dub can't read files from cache

2014-09-18 Thread AsmMan via Digitalmars-d-learn
On Thursday, 18 September 2014 at 16:51:06 UTC, ketmar via Digitalmars-d-learn wrote: On Thu, 18 Sep 2014 16:31:08 + Ilya Yaroshenko via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: one ring to rule them all UTF-8 = Lord of the encodings. i want 42th symbol from the string.

Re: dub can't read files from cache

2014-09-18 Thread AsmMan via Digitalmars-d-learn
On Thursday, 18 September 2014 at 16:49:14 UTC, ketmar via Digitalmars-d-learn wrote: On Thu, 18 Sep 2014 16:24:17 + Ilya Yaroshenko via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: You can choice encoding for console in Linux yes. and i chose koi8. yet many utilities tend

Re: commercial application with D

2014-09-15 Thread AsmMan via Digitalmars-d-learn
On Monday, 15 September 2014 at 20:45:38 UTC, Ali Çehreli wrote: On 09/15/2014 01:02 PM, Andrey wrote: Can I develop commercial application with D programming language? Here is a short list of companies that do that: http://wiki.dlang.org/Current_D_Use Ali Good list.

Re: how to transform decial point 3.15 to 3,15 comma?

2014-09-15 Thread AsmMan via Digitalmars-d-learn
On Monday, 15 September 2014 at 22:45:50 UTC, Cassio Butrico wrote: how to transform decial point 3.15 to 3,15 comma? Hello everyone, I am making a registry of real amounts, and need trasformar fractional numbers, so print coretamente. there is some routine that do this? Is the , (comma) the

Re: how to transform decial point 3.15 to 3,15 comma?

2014-09-15 Thread AsmMan via Digitalmars-d-learn
On Monday, 15 September 2014 at 23:17:51 UTC, AsmMan wrote: On Monday, 15 September 2014 at 22:45:50 UTC, Cassio Butrico wrote: how to transform decial point 3.15 to 3,15 comma? Hello everyone, I am making a registry of real amounts, and need trasformar fractional numbers, so print

How do I properly exit from a D program (outside main)?

2014-09-15 Thread AsmMan via Digitalmars-d-learn
Someone said somewhere that call std.c.process.exit() isn't the proper way to exit from a D program since it doesn't terminate some phobos stuff. So what should I use instead of? or there's no a replacement?

Re: core.exception.UnicodeException@src\rt\util\utf.d(400): illegal UTF-16 value

2014-09-15 Thread AsmMan via Digitalmars-d-learn
On Monday, 15 September 2014 at 23:57:59 UTC, Ali Çehreli wrote: On 09/15/2014 04:36 PM, notna wrote: WCHAR lpwszUsername[254]; debug writefln(lpwszUsername.sizeof is %s, WCHAR.sizeof is %s, lpwszUsername.sizeof, WCHAR.sizeof); // DWORD dUsername2 =

Re: how to transform decial point 3.15 to 3,15 comma?

2014-09-15 Thread AsmMan via Digitalmars-d-learn
On Monday, 15 September 2014 at 23:43:47 UTC, Cassio Butrico wrote: On Monday, 15 September 2014 at 23:24:13 UTC, AsmMan wrote: On Monday, 15 September 2014 at 23:17:51 UTC, AsmMan wrote: On Monday, 15 September 2014 at 22:45:50 UTC, Cassio Butrico wrote: how to transform decial point 3.15 to

Re: How do I properly exit from a D program (outside main)?

2014-09-15 Thread AsmMan via Digitalmars-d-learn
On Monday, 15 September 2014 at 23:52:25 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Mon, Sep 15, 2014 at 11:36:54PM +, AsmMan via Digitalmars-d-learn wrote: Someone said somewhere that call std.c.process.exit() isn't the proper way to exit from a D program since it doesn't terminate

Re: How do I properly exit from a D program (outside main)?

2014-09-15 Thread AsmMan via Digitalmars-d-learn
On Monday, 15 September 2014 at 23:42:02 UTC, notna wrote: how about return? :) there is also assert... and pls note, scope could also be your friend :O On Monday, 15 September 2014 at 23:36:56 UTC, AsmMan wrote: Someone said somewhere that call std.c.process.exit() isn't the proper way to

when should I use a function call without parenteses?

2014-09-15 Thread AsmMan via Digitalmars-d-learn
In which context do you use a function call without paranteses? (considering the function doesn't has arguments or they're default, of couse) I want to know when/why should I use or if it depends only to programmer's coding style.. f / baa.foo versus f() / baa.foo() personally, to me,

Re: String Theory Questions

2014-09-14 Thread AsmMan via Digitalmars-d-learn
On Saturday, 13 September 2014 at 23:21:09 UTC, David Nadlinger wrote: On Saturday, 13 September 2014 at 22:41:39 UTC, AsmMan wrote: D string are actullay C-strings? No. But string *literals* are guaranteed to be 0-terminated for easier interoperability with C code. David ah makes sense.

Re: String Theory Questions

2014-09-13 Thread AsmMan via Digitalmars-d-learn
On Saturday, 13 September 2014 at 17:31:18 UTC, ketmar via Digitalmars-d-learn wrote: On Sat, 13 Sep 2014 17:09:56 + WhatMeWorry via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I guess I was expecting them to be equivalent. I can understand why both lengths are zero.

Re: Is º an unicode alphabetic character?

2014-09-12 Thread AsmMan via Digitalmars-d-learn
On Friday, 12 September 2014 at 04:04:22 UTC, Ali Çehreli wrote: On 09/11/2014 08:04 PM, AsmMan wrote: what's an unicode alphabetic character? Alphabetic is defined as Lu + Ll + Lt + Lm + Lo + Nl + Other_Alphabetic, all of which are explained here:

Re: Is º an unicode alphabetic character?

2014-09-12 Thread AsmMan via Digitalmars-d-learn
On Friday, 12 September 2014 at 07:57:43 UTC, Ali Çehreli wrote: On 09/11/2014 11:38 PM, AsmMan wrote: If I want ASCII and latin only alphabet which range should I use? ie, how should I rewrite is_id() function? This seems to be it: import std.stdio; import std.uni; void main() { alias

Re: Is º an unicode alphabetic character?

2014-09-12 Thread AsmMan via Digitalmars-d-learn
Thanks Ali, I think I get close: bool is_id(dchar c) { return c = 'a' c = 'z' || c = 'A' c = 'Z' || c = 0xc0 c = 0x0d || c = 0xd8 c = 0xf6 || c = 0xf8 c = 0xff; } this doesn't include some math symbols. like c = 0xc0 did.

Is º an unicode alphabetic character?

2014-09-11 Thread AsmMan via Digitalmars-d-learn
what's an unicode alphabetic character? I misunderstood isAlpha(), I used to think it's to validate letters like a, b, è, é .. z etc but isAlpha('º') from std.uni module return true. How can I validate only the letters of an unicode alphabet in D or should I write one? I know I can do: bool

Re: Novice web developer trying to learn D

2014-09-08 Thread AsmMan via Digitalmars-d-learn
On Sunday, 7 September 2014 at 21:06:48 UTC, zuzuleinen wrote: Hello, First, here is my Linkedin profile http://www.linkedin.com/in/andreiboar in order to make an image of my professional background. I do realise here are really good programmers for which this background might sound like a

Re: Allowing Expressions such as (low value high)

2014-09-07 Thread AsmMan via Digitalmars-d-learn
On Thursday, 4 September 2014 at 20:33:45 UTC, Nordlöw wrote: On Thursday, 4 September 2014 at 20:25:52 UTC, monarch_dodra wrote: In the case of D, it's a C compatibility thing. Other languages I don't know. FYI, auto x = 1 2 3; as C++ is accepted (but warned about) by GCC as

Register allocation algorithm

2014-05-06 Thread asmman via Digitalmars-d-learn
I'm working on small compiler to understand these stuff and maybe get involved with the D compiler. I wrote a front-end to a C-like language and now I'm working on the code generator. To be more specific, in the register allocation phase. I was using a old and one where I put everything on