Re: execute bash?

2016-04-10 Thread Puming via Digitalmars-d-learn
On Sunday, 10 April 2016 at 10:43:48 UTC, wobbles wrote: This would be cool. I'll have a think about how to go about it! Looking forward to your updates! :P

Re: execute bash?

2016-04-10 Thread Puming via Digitalmars-d-learn
On Sunday, 10 April 2016 at 02:59:41 UTC, Adam D. Ruppe wrote: On Sunday, 10 April 2016 at 00:47:28 UTC, Puming wrote: 3. when hiting 'vim a.file' on the command, things go messy. Have you got these interactive commands work in dexpect? It is surely capturing exactly what vim sends to a termin

Re: execute bash?

2016-04-09 Thread Puming via Digitalmars-d-learn
On Saturday, 9 April 2016 at 08:56:17 UTC, wobbles wrote: On Friday, 8 April 2016 at 23:06:06 UTC, Puming wrote: On Friday, 8 April 2016 at 18:23:32 UTC, wobbles wrote: On Friday, 8 April 2016 at 16:07:13 UTC, Adam D. Ruppe wrote: On Friday, 8 April 2016 at 15:20:09 UTC, Puming wrote: I tried

Re: execute bash?

2016-04-08 Thread Puming via Digitalmars-d-learn
On Friday, 8 April 2016 at 16:16:27 UTC, Adam D. Ruppe wrote: On Friday, 8 April 2016 at 15:31:13 UTC, Puming wrote: The D version behavior is strange. Are you still calling bash? Cuz that is going to complicate things a lot because bash does its own signal handling too and could be intercep

Re: execute bash?

2016-04-08 Thread Puming via Digitalmars-d-learn
On Friday, 8 April 2016 at 18:23:32 UTC, wobbles wrote: On Friday, 8 April 2016 at 16:07:13 UTC, Adam D. Ruppe wrote: On Friday, 8 April 2016 at 15:20:09 UTC, Puming wrote: I tried with signal, but didn't catch SIGTTOU, it seems that spawnProcess with `bash -i -c` will signal with SIGTTIN. Oh

Re: execute bash?

2016-04-08 Thread Puming via Digitalmars-d-learn
On Friday, 8 April 2016 at 16:08:02 UTC, Adam D. Ruppe wrote: On Friday, 8 April 2016 at 14:09:16 UTC, Puming wrote: I just found that you have terminal.d in arsd repo, are you writing a repl with it? I'm hoping I might be able to use it. I have done it before. terminal.d has a getline functio

Re: execute bash?

2016-04-08 Thread Puming via Digitalmars-d-learn
On Friday, 8 April 2016 at 16:07:13 UTC, Adam D. Ruppe wrote: On Friday, 8 April 2016 at 15:20:09 UTC, Puming wrote: I tried with signal, but didn't catch SIGTTOU, it seems that spawnProcess with `bash -i -c` will signal with SIGTTIN. Oh, surely because it wants to be interactive and is thus

Re: execute bash?

2016-04-08 Thread Puming via Digitalmars-d-learn
On Friday, 8 April 2016 at 13:25:37 UTC, Adam D. Ruppe wrote: On Friday, 8 April 2016 at 13:23:10 UTC, Adam D. Ruppe wrote: Odds are it is that there's terminal output for the background process NOT a character btw, just any output, then the OS puts you on hold so it can do its thing. To ca

Re: execute bash?

2016-04-08 Thread Puming via Digitalmars-d-learn
On Friday, 8 April 2016 at 13:25:37 UTC, Adam D. Ruppe wrote: On Friday, 8 April 2016 at 13:23:10 UTC, Adam D. Ruppe wrote: Odds are it is that there's terminal output for the background process NOT a character btw, just any output, then the OS puts you on hold so it can do its thing. To ca

Re: execute bash?

2016-04-08 Thread Puming via Digitalmars-d-learn
On Friday, 8 April 2016 at 13:23:10 UTC, Adam D. Ruppe wrote: On Friday, 8 April 2016 at 10:08:07 UTC, Puming wrote: but with each command loop, the program is stopped (equal to Ctrl-Z). Your program is stopped, right? Odds are it is that there's terminal output for the background process, w

execute bash?

2016-04-08 Thread Puming via Digitalmars-d-learn
Hi, I'd like to write an interactive commmand line tool for my commands, and that also support bash commands. My first thinking is 'why not just execute those bash commands with bash'? But it turns out to have some problem. When I use executeShell, I found that .bashrc is not loaded so tha

Re: is std.algorithm.joiner lazy?

2016-04-08 Thread Puming via Digitalmars-d-learn
On Friday, 8 April 2016 at 08:44:36 UTC, Mike Parker wrote: On Friday, 8 April 2016 at 03:20:53 UTC, Puming wrote: On Friday, 8 April 2016 at 02:49:01 UTC, Jonathan M Davis wrote: [...] Thanks. I'll adopt this idiom. Hopefully it gets used often enough to warrent a phobos function :-) What

Re: is std.algorithm.joiner lazy?

2016-04-07 Thread Puming via Digitalmars-d-learn
On Friday, 8 April 2016 at 02:49:01 UTC, Jonathan M Davis wrote: [...] Thanks. I'll adopt this idiom. Hopefully it gets used often enough to warrent a phobos function :-)

Re: how to parse a string into a phobos datatype with additional logic

2016-04-07 Thread Puming via Digitalmars-d-learn
On Thursday, 7 April 2016 at 11:07:35 UTC, Marc Schütz wrote: On Thursday, 7 April 2016 at 08:06:03 UTC, Puming wrote: On Thursday, 7 April 2016 at 07:45:06 UTC, yawniek wrote: what is the way one is supposed to parse e.g. a double of unixtime (as delived by nginx logs) into a SysTime? current

Re: is std.algorithm.joiner lazy?

2016-04-07 Thread Puming via Digitalmars-d-learn
On Friday, 8 April 2016 at 01:14:11 UTC, Jonathan M Davis wrote: [...] Well, given your example, I would strongly argue that you should write a range that calls read in its constructor and in popFront rather (so that calling front multiple times doesn't matter) rather than using map. While ma

Re: is std.algorithm.joiner lazy?

2016-04-07 Thread Puming via Digitalmars-d-learn
On Friday, 8 April 2016 at 01:14:11 UTC, Jonathan M Davis wrote: [...] Lazy means that it's not going to consume the entire range when you call the function. Rather, it's going to return a range that you can iterate over. It may or may not process the first element before returning, depending

Re: is std.algorithm.joiner lazy?

2016-04-07 Thread Puming via Digitalmars-d-learn
On Thursday, 7 April 2016 at 18:15:07 UTC, Jonathan M Davis wrote: On Thursday, April 07, 2016 08:47:15 Puming via Digitalmars-d-learn wrote: On Thursday, 7 April 2016 at 08:27:23 UTC, Edwin van Leeuwen wrote: > On Thursday, 7 April 2016 at 08:17:38 UTC, Puming wrote: >> On Thursday

Re: is std.algorithm.joiner lazy?

2016-04-07 Thread Puming via Digitalmars-d-learn
On Thursday, 7 April 2016 at 10:57:25 UTC, Edwin van Leeuwen wrote: On Thursday, 7 April 2016 at 09:55:56 UTC, Puming wrote: [...] That seems like a bug to me and you might want to submit it to the bug tracker. Even converting it to an array first does not seem to work: [...] Thanks. I j

Re: is std.algorithm.joiner lazy?

2016-04-07 Thread Puming via Digitalmars-d-learn
On Thursday, 7 April 2016 at 08:27:23 UTC, Edwin van Leeuwen wrote: On Thursday, 7 April 2016 at 08:17:38 UTC, Puming wrote: On Thursday, 7 April 2016 at 08:07:12 UTC, Edwin van Leeuwen wrote: OK. Even if it consumes the first two elements, then why does it have to consume them AGAIN when act

Re: is std.algorithm.joiner lazy?

2016-04-07 Thread Puming via Digitalmars-d-learn
On Thursday, 7 April 2016 at 08:27:23 UTC, Edwin van Leeuwen wrote: On Thursday, 7 April 2016 at 08:17:38 UTC, Puming wrote: On Thursday, 7 April 2016 at 08:07:12 UTC, Edwin van Leeuwen wrote: OK. Even if it consumes the first two elements, then why does it have to consume them AGAIN when act

Re: is std.algorithm.joiner lazy?

2016-04-07 Thread Puming via Digitalmars-d-learn
On Thursday, 7 April 2016 at 08:07:12 UTC, Edwin van Leeuwen wrote: On Thursday, 7 April 2016 at 07:07:40 UTC, Puming wrote: [...] Apparently it works processing the first two elements at creation. All the other elements will be processed lazily. Even when a range is lazy the algorithm stil

Re: how to parse a string into a phobos datatype with additional logic

2016-04-07 Thread Puming via Digitalmars-d-learn
On Thursday, 7 April 2016 at 07:45:06 UTC, yawniek wrote: what is the way one is supposed to parse e.g. a double of unixtime (as delived by nginx logs) into a SysTime? currently i'm creating a wrapper struct around SysTime with alias this as: https://gist.github.com/yannick/6caf5a5184beea0c24

is std.algorithm.joiner lazy?

2016-04-07 Thread Puming via Digitalmars-d-learn
Hi: when I use map with joiner, I found that function in map are called. In the document it says joiner is lazy, so why is the function called? say: int[] mkarray(int a) { writeln("mkarray called!"); return [a * 2]; // just for test } void main() { auto xs = [1, 2]; auto r = xs.

Re: Build release and debug with dub

2016-04-06 Thread Puming via Digitalmars-d-learn
On Thursday, 7 April 2016 at 02:07:18 UTC, Puming wrote: On Wednesday, 6 April 2016 at 19:49:38 UTC, Suliman wrote: [...] In the document it says you can not specify targetName in buildType. I wonder why is that? But you can use two configurations like this(assumming your project is named

Re: Build release and debug with dub

2016-04-06 Thread Puming via Digitalmars-d-learn
On Wednesday, 6 April 2016 at 19:49:38 UTC, Suliman wrote: Is it's possible to make rule, that allow to build two version of App? One release and one debug at same time. I looked at "buildTypes" https://code.dlang.org/package-format?lang=json But it's not possible to set different names for ou

Re: infer type argument in classe constructor?

2016-03-29 Thread Puming via Digitalmars-d-learn
On Tuesday, 29 March 2016 at 10:29:46 UTC, Simen Kjaeraas wrote: On Tuesday, 29 March 2016 at 10:13:28 UTC, Puming wrote: Hi, I'm writing a generic class: ```d struct Message { ... } class Decoder(MsgSrc) { } ``` When using it, I'd have to include the type of its argument: ``` void main()

infer type argument in classe constructor?

2016-03-29 Thread Puming via Digitalmars-d-learn
Hi, I'm writing a generic class: ```d struct Message { ... } class Decoder(MsgSrc) { } ``` When using it, I'd have to include the type of its argument: ``` void main() { Message[] src = ...; auto decoder = new Decoder!(Message[])(src); ... } ``` Can it be inferred so that I only

Re: string and char[] in Phobos

2016-03-29 Thread Puming via Digitalmars-d-learn
On Friday, 18 March 2016 at 20:06:27 UTC, Jonathan M Davis wrote: When a function accepts const(char)[] than it can accept char[], const(char)[], const(char[]), immutable(char)[], and immutable(char[]), which, whereas if it accepts string, then all it accepts are immutable(char)[] and immutabl

string and char[] in Phobos

2016-03-19 Thread Puming via Digitalmars-d-learn
Hi, I saw from the forum that functions with string like arguments better use `in char[]` instead of `string` type, because then it can accept both string and char[] types. But recently when actually using D, I found that many phobos functions/constructors use `string`, while many returns `c

Re: What is the best declaration type for a string like parameter?

2016-01-28 Thread Puming via Digitalmars-d-learn
On Thursday, 28 January 2016 at 15:10:38 UTC, Adam D. Ruppe wrote: But for just both string and char[], yeah, const is the way to do it. [...] Thanks for the clear explaination. So `in char[]` is stricter (and safer) than `const(char)[]`. I will stick to that.

Re: What is the best declaration type for a string like parameter?

2016-01-28 Thread Puming via Digitalmars-d-learn
On Thursday, 28 January 2016 at 15:03:38 UTC, sigod wrote: On Thursday, 28 January 2016 at 13:36:46 UTC, Puming wrote: [...] `in char[]` is short for `scope const char[]` or `scope const(char[])`. See http://dlang.org/spec/function.html#parameters It depends on the situation. If possible I

What is the best declaration type for a string like parameter?

2016-01-28 Thread Puming via Digitalmars-d-learn
I have a function that reads a line of string and do some computation. I searched the forum and found that people use `const(char)[]` or `in char[]` to accept both string and char[] arguments. What's the difference between `const(char)[]` and `in char[]`? If they are not the same, then whic

Re: Multiple range enumeration

2015-11-10 Thread puming via Digitalmars-d-learn
On Wednesday, 11 November 2015 at 02:55:25 UTC, cym13 wrote: On Wednesday, 11 November 2015 at 02:38:19 UTC, puming wrote: Hi, If I have multiple ranges, say: auto a = [1, 2, 3]; auto b = ["a", "b", "c"]; auto c = ["x", "y", "z"]; I'd like a composition range that enumerate all combinations

Multiple range enumeration

2015-11-10 Thread puming via Digitalmars-d-learn
Hi, If I have multiple ranges, say: auto a = [1, 2, 3]; auto b = ["a", "b", "c"]; auto c = ["x", "y", "z"]; I'd like a composition range that enumerate all combinations of these ranges, having the same effect as a nested foreach loop: foreach (i; a) { foreach (j; b) { foreach (k; c) {

Re: sdlang-d can not link after updating to dmd 2.066

2014-08-28 Thread Puming via Digitalmars-d-learn
I updated dub to 0.9.22 and still got the same error... THis is the output of `dub build --force`: --- output --- ## Warning for package sdlang-d ## The following compiler flags have been specified in the package description file. They are handled by DUB and direct use in packages is discour

sdlang-d can not link after updating to dmd 2.066

2014-08-27 Thread Puming via Digitalmars-d-learn
Hi, I'm using sdlang-d version 0.8.4 (http://code.dlang.org/packages/sdlang-d). When I update dmd to version 2.066 today, I found that sdlang-d won't link, with these errors: Undefined symbols for architecture x86_64: "_D7sdlang_3ast3Tag103__T11MemberRangeTC7sdlang_3ast3TagVAyaa7_616c6c5

Re: Are there desktop appications being developed in D currently?

2014-08-10 Thread Puming via Digitalmars-d-learn
On Sunday, 10 August 2014 at 18:40:23 UTC, Adam D. Ruppe wrote: On Sunday, 10 August 2014 at 14:28:33 UTC, Puming wrote: What do you mean by 'boring'? I think a shell in D would be awesome. tbh I think shells are a bit boring too, but like you said in the other message, they are two different

Re: Are there desktop appications being developed in D currently?

2014-08-10 Thread Puming via Digitalmars-d-learn
Sorry for my misunderstanding. After looking at your code I realized that your terminal emulator is a GUI application and I was responding about a shell :-) Nonetheless, a terminal emulator is a very interesting tool. On Sunday, 10 August 2014 at 13:25:32 UTC, Adam D. Ruppe wrote: My thing wo

Re: Are there desktop appications being developed in D currently?

2014-08-10 Thread Puming via Digitalmars-d-learn
Wow, it just happens that I checked your terminal.d code on the list an hour ago :-) Definitely gonna look at it. What do you mean by 'boring'? I think a shell in D would be awesome. I'm planning to make a shell scripting lib in D, I would like it to be very powerful, but my coding skills

Re: Are there desktop appications being developed in D currently?

2014-08-10 Thread Puming via Digitalmars-d-learn
On Sunday, 10 August 2014 at 05:34:49 UTC, thedeemon wrote: On Sunday, 10 August 2014 at 04:41:45 UTC, Puming wrote: Photo processing app: Disk space visualizer and redundancy searcher: A tool for watching some folders and processing video files there... Interesting :-) Unfortunately they

Re: Are there desktop appications being developed in D currently?

2014-08-09 Thread Puming via Digitalmars-d-learn
Interesting :-) Unfortunately they are all windows only apps, I don't have a windows machine. Can I link them on my bookmarks about D projects? https://github.com/zhaopuming/awesome-d On Saturday, 9 August 2014 at 17:14:39 UTC, thedeemon wrote: On Saturday, 9 August 2014 at 00:34:43 UTC, P

Re: Are there desktop appications being developed in D currently?

2014-08-09 Thread Puming via Digitalmars-d-learn
On Saturday, 9 August 2014 at 15:19:35 UTC, ketmar via Digitalmars-d-learn wrote: On Sat, 09 Aug 2014 00:34:42 + Puming via Digitalmars-d-learn wrote: yes, there is. all of ours apps are done with D and GtkD now. alas, it's in-house, but alot of people using them. ;-) Can you gi

Re: Are there desktop appications being developed in D currently?

2014-08-09 Thread Puming via Digitalmars-d-learn
On Saturday, 9 August 2014 at 21:46:45 UTC, Peter Alexander wrote: On Saturday, 9 August 2014 at 00:34:43 UTC, Puming wrote: Yes, rust is a more infantile language compared to D, but people are already using them to create complicate applications like browser! Rust was designed to build Servo

Re: Are there desktop appications being developed in D currently?

2014-08-08 Thread Puming via Digitalmars-d-learn
On Saturday, 9 August 2014 at 01:26:05 UTC, ed wrote: On Saturday, 9 August 2014 at 00:34:43 UTC, Puming wrote: Hi, I bumped into a blog talking about building a (toy) browser engine in Rust: (http://limpet.net/mbrubeck/2014/08/08/toy-layout-engine-1.html) In the blog I found that the OP is

Are there desktop appications being developed in D currently?

2014-08-08 Thread Puming via Digitalmars-d-learn
Hi, I bumped into a blog talking about building a (toy) browser engine in Rust: (http://limpet.net/mbrubeck/2014/08/08/toy-layout-engine-1.html) In the blog I found that the OP is in the mozilla servo team building a parallel browser for mozilla. The servo is hosted on github here: (https

Re: Member access of __gshared global object

2014-08-07 Thread Puming via Digitalmars-d-learn
Yes indeed, null initial value is reasonable. My suggestion does not affect that rationale, but is only based on my observation that if someone want to `refer` to an AA, he is more likely to fill it very soon, and he really mean to refer to it. These are similar concerns: - create a null AA,

Re: Member access of __gshared global object

2014-08-06 Thread Puming via Digitalmars-d-learn
ed AA. Actually, I think ANY structs that mimics a reference behavior should add this rule to really look like a reference. On Thursday, 7 August 2014 at 02:17:19 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Thu, Aug 07, 2014 at 02:00:27AM +0000, Puming via Digitalmars-d-learn wrote

Re: Member access of __gshared global object

2014-08-06 Thread Puming via Digitalmars-d-learn
On Wednesday, 6 August 2014 at 15:42:05 UTC, Marc Schütz wrote: On Wednesday, 6 August 2014 at 15:18:15 UTC, Dragos Carp wrote: On Wednesday, 6 August 2014 at 14:36:23 UTC, Marc Schütz wrote: This would defeat the purpose, see the original post. sorry, I red just the last post. __gshared ha

Re: AA initialization

2014-08-06 Thread Puming via Digitalmars-d-learn
On Wednesday, 6 August 2014 at 14:38:34 UTC, Marc Schütz wrote: On Wednesday, 6 August 2014 at 13:15:27 UTC, Kozzi11 wrote: AFAIK there is no easy way to do it. Maybe it would be fine to add some function to phobos. Something like this: auto initAA(VT,KT)() { static struct Entry

AA initialization

2014-08-06 Thread Puming via Digitalmars-d-learn
I found AA initialization have a strange effect: ```d string[string] map; // same as `string[string] map = string[string].init; writeln(map); // output: [] string[string] refer = map; // make a reference refer["1"] = "2"; // update the reference writeln(map); // outpu

Re: HTP Handler

2014-08-05 Thread Puming via Digitalmars-d-learn
See this list: https://github.com/zhaopuming/awesome-d#web-frameworks On Wednesday, 6 August 2014 at 04:10:28 UTC, HUSSAIN wrote: Hi , I am new to D, I would like to build HTTP Server in D. Can any one throw some light on what are all the libraries available in D and if there is any exampl

Re: Member access of __gshared global object

2014-08-05 Thread Puming via Digitalmars-d-learn
On Thursday, 31 July 2014 at 10:22:28 UTC, Marc Schütz wrote: On Thursday, 31 July 2014 at 02:03:37 UTC, Puming wrote: 1. Are AAs reference type? if so, why does the compiler copy it? This is probably your problem. They are reference types, but initially that reference is `null`. When you wri

Member access of __gshared global object

2014-07-30 Thread Puming via Digitalmars-d-learn
Hi, I'm writing this global Config class, with an AA member: ```d module my.config; class Config { Command[string] commands; } __gshared Config CONFIG; ``` and initialize it in another module: ```d module my.app; import my.config; void main() { CONFIG = new Config(); CONFIG.command

Re: fork/waitpid and std.concurrency.spawn

2014-07-23 Thread Puming via Digitalmars-d-learn
OK, I understand your point :-) On Wednesday, 23 July 2014 at 09:05:49 UTC, FreeSlave wrote: Seems like you need inter process communication. There are many ways to make one. For example, through sockets. You may use D bindings to ZMQ or other library, or just use std.socket. Anyway the proces

Re: fork/waitpid and std.concurrency.spawn

2014-07-23 Thread Puming via Digitalmars-d-learn
OK, I see your point. I didn't know much about windows, so didn't know that fork in windows was so different from posix. This looks reasonable. What I really want is a actor modal similar to std.concurrency, with a similar API and spawn/send/replay semantics, but using processes instead of th

Re: fork/waitpid and std.concurrency.spawn

2014-07-22 Thread Puming via Digitalmars-d-learn
I've only found spawnProcess/spawnShell and the like, which executes a new command, but not a function pointer, like fork() and std.concurrency.spawn does. What is the function that does what I describe? On Tuesday, 22 July 2014 at 10:43:58 UTC, FreeSlave wrote: On Tuesday, 22 July 2014 at 07

fork/waitpid and std.concurrency.spawn

2014-07-22 Thread Puming via Digitalmars-d-learn
Is there a fork()/wait() API similar to std.concurrency spawn()? The best thing I've got so far is module core.sys.posix.unistd.fork(), but it seems to only work in posix. Is there a unified API for process level concurrency? ideally with actor and send message support too.

Re: How can I express the type '(int) => int' where it is a function or a delegate

2014-07-15 Thread Puming via Digitalmars-d-learn
On Wednesday, 16 July 2014 at 04:10:13 UTC, Rikki Cattermole wrote: On 16/07/2014 3:50 p.m., Puming wrote: I'd like to have a Command class, where their is a name and a handler field: ```d class Command { string name; string delegate(string[]) handler; } ``` this is ok, but sometimes I wa

How can I express the type '(int) => int' where it is a function or a delegate

2014-07-15 Thread Puming via Digitalmars-d-learn
I'd like to have a Command class, where their is a name and a handler field: ```d class Command { string name; string delegate(string[]) handler; } ``` this is ok, but sometimes I want the handler also accept a function (lambdas are init to functions if no capture of outer scope variables

Re: lazy construction of an immutable object

2014-07-15 Thread Puming via Digitalmars-d-learn
On Tuesday, 15 July 2014 at 17:09:04 UTC, Meta wrote: On Tuesday, 15 July 2014 at 15:48:10 UTC, Puming wrote: wow, that's interesting :-) Is it the idiomatic approach to initiate immutable objects lazily? Or do people use data class with immutable fields and generate a companion builder class

Re: lazy construction of an immutable object

2014-07-15 Thread Puming via Digitalmars-d-learn
On Tuesday, 15 July 2014 at 13:59:24 UTC, Ali Çehreli wrote: On 07/15/2014 05:20 AM, Puming wrote: I found another way to do this, namely first create a class that is mutable, then cast it to an immutable object before using it. ```d class A { int a; B b; this(int a, int b) {

Re: lazy construction of an immutable object

2014-07-15 Thread Puming via Digitalmars-d-learn
I found another way to do this, namely first create a class that is mutable, then cast it to an immutable object before using it. ```d class A { int a; B b; this(int a, int b) { this.a = a; this.b = new B(b); } } class B

lazy construction of an immutable object

2014-07-15 Thread Puming via Digitalmars-d-learn
Hi, I'd like to use immutable data, but instead of a one time constructor, I would like to `build` the data lazily, by setting its fields separately. In java version of protocol-buffer, there is a pattern for this mechanism: 1. Every data class in protobuf is immutable. 2. Each data class

Re: new properties for basic types

2014-07-14 Thread Puming via Digitalmars-d-learn
On Monday, 14 July 2014 at 10:28:30 UTC, Dominikus Dittes Scherkl wrote: Is it possible to write custom properties for basic types, so that I can write e.g. "int.myProp" instead of "myProp!int()" [analogue to x.myProp instead of myProp(x)]? yes, just define a funciton with the first parameter

Re: spawn and wait

2014-07-03 Thread Puming via Digitalmars-d-learn
On Thursday, 3 July 2014 at 04:51:07 UTC, Ali Çehreli wrote: On 07/02/2014 08:29 PM, Puming wrote: > I want to spawn several similar tasks and then wait for all of them to > complete to go on do some other things If you don't care about account for each of them individually, core.thread.thread

spawn and wait

2014-07-02 Thread Puming via Digitalmars-d-learn
Hi, I want to spawn several similar tasks and then wait for all of them to complete to go on do some other things, like: ```d void task(int id) { // do the stuff } void main() { foreach (i; 0..10) { spawn(&task, i); } wait(?); // wait for all task to complete doSomeOtherThings()

Re: struct, ref in, and UFCS

2014-07-01 Thread Puming via Digitalmars-d-learn
On Tuesday, 1 July 2014 at 13:53:12 UTC, Ali Çehreli wrote: On 07/01/2014 03:21 AM, Puming wrote: > I can safely assume ref is better than pointer here I agree. > because it plays nicely with UFCS. I don't understand that part. :) The following is the same program with just two differences:

Re: struct, ref in, and UFCS

2014-07-01 Thread Puming via Digitalmars-d-learn
On Tuesday, 1 July 2014 at 07:53:27 UTC, bearophile wrote: Puming: is this a good practice to use `ref in` with structs instead of traditional pointer syntax (which does not play well with UFCS though) ? Is there any perfomance implications with `ref in`? I tried that it does not seem to copy

Re: struct, ref in, and UFCS

2014-06-30 Thread Puming via Digitalmars-d-learn
On Tuesday, 1 July 2014 at 05:26:47 UTC, Ali Çehreli wrote: On 06/30/2014 10:11 PM, Puming wrote: > On Tuesday, 1 July 2014 at 05:09:49 UTC, Puming wrote: >> Hi, >> >> I have a struct and want to extends its methods, like: >> >> ```d >> struct Server >> { >> string name; >> string ip; >> i

Re: struct, ref in, and UFCS

2014-06-30 Thread Puming via Digitalmars-d-learn
On Tuesday, 1 July 2014 at 05:09:49 UTC, Puming wrote: Hi, I have a struct and want to extends its methods, like: ```d struct Server { string name; string ip; int port; string user; } ``` extension method here: ```d string prompt(ref in Server server) { return server.user ~ "@" ~ s

struct, ref in, and UFCS

2014-06-30 Thread Puming via Digitalmars-d-learn
Hi, I have a struct and want to extends its methods, like: ```d struct Server { string name; string ip; int port; string user; } ``` extension method here: ```d string prompt(ref in Server server) { return server.user ~ "@" ~ server.ip ~ ":" ~ server.port; } ``` and call it with U

Re: import except one?

2014-06-29 Thread Puming via Digitalmars-d-learn
On Sunday, 29 June 2014 at 07:28:12 UTC, Kapps wrote: A bit late, but you should also be able to do: import scriptlike; alias Config = std.process.Config; Thanks, so an alias or an additional single symbol import will shadow the earlier imported symbol. That's fine for me :-)

Re: import except one?

2014-06-26 Thread Puming via Digitalmars-d-learn
On Thursday, 26 June 2014 at 08:02:24 UTC, bearophile wrote: Puming: I'm using scriptlike, which imports everything from std.process for convienience, but I also need to import another module, which contains a class `Config`, it conflicts with std.process.Config. I don't actually need std.pr

Re: import except one?

2014-06-26 Thread Puming via Digitalmars-d-learn
On Thursday, 26 June 2014 at 16:02:15 UTC, sigod wrote: Dirty solution: ``` import scriptlike; import your_module; import your_module : Config; ``` So, `Config` from your module will override one from scriptlike. I'm currenly renaming my own symbol: ```d import scriptlike; import config : Cf

import except one?

2014-06-26 Thread Puming via Digitalmars-d-learn
Hi, I'm using scriptlike, which imports everything from std.process for convienience, but I also need to import another module, which contains a class `Config`, it conflicts with std.process.Config. I don't actually need std.process.Config, but I need many other symbols in scriptlike and std.