Re: Setting a list of values

2016-05-07 Thread sigod via Digitalmars-d-learn
On Monday, 2 May 2016 at 23:41:39 UTC, Steven Schveighoffer wrote: On 5/2/16 6:00 PM, sigod wrote: On Monday, 2 May 2016 at 10:15:04 UTC, Marc Schütz wrote: On Monday, 2 May 2016 at 08:46:31 UTC, Ali Çehreli wrote: [...] Warning (better: disallowing altogether) about `=>` directly followed

Re: Setting a list of values

2016-05-07 Thread sigod via Digitalmars-d-learn
On Wednesday, 4 May 2016 at 04:56:54 UTC, Joel wrote: On Sunday, 1 May 2016 at 05:42:00 UTC, Ali Çehreli wrote: [...] This seems to work the best: arr.each!(a => { writeln(a); }()); And the ugliest. And probably slowest.

Re: Setting a list of values

2016-05-02 Thread sigod via Digitalmars-d-learn
On Monday, 2 May 2016 at 10:15:04 UTC, Marc Schütz wrote: On Monday, 2 May 2016 at 08:46:31 UTC, Ali Çehreli wrote: [...] Warning (better: disallowing altogether) about `=>` directly followed by `{` should be enough to cover all cases. To express that you really want a lambda returning a

Re: relative benefit of .reserve and .length

2016-04-29 Thread sigod via Digitalmars-d-learn
On Thursday, 28 April 2016 at 14:08:26 UTC, Steven Schveighoffer wrote: On 4/28/16 8:56 AM, Jay Norwood wrote: [...] .reserve should make an improvement for large amount of appending, since you pre-allocate the data. [...] How about `assumeSafeAppend`? Does it have any positive impact on

Re: Iterating over thread local storage variables

2016-03-11 Thread sigod via Digitalmars-d-learn
On Friday, 11 March 2016 at 18:45:13 UTC, Anonymouse wrote: On Friday, 11 March 2016 at 17:33:43 UTC, sigod wrote: On Friday, 11 March 2016 at 17:03:38 UTC, Anonymouse wrote: On Friday, 11 March 2016 at 15:21:38 UTC, maik klein wrote: [...] As a drive-by comment, mind that

Re: Iterating over thread local storage variables

2016-03-11 Thread sigod via Digitalmars-d-learn
On Friday, 11 March 2016 at 17:03:38 UTC, Anonymouse wrote: On Friday, 11 March 2016 at 15:21:38 UTC, maik klein wrote: static Singleton!T get() { if (!instantiated_) { synchronized(Singleton!T.classinfo){ if (!instance_){

Re: In language tooling

2016-03-02 Thread sigod via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 02:36:50 UTC, Charles wrote: Watched a video on Jonathan Blow's language that he's developing, and he has a pretty neat idea of having tools being part of the language. Looking at the first 15 minutes(https://www.youtube.com/watch?v=OHZwYYW9koI) or so of the

Re: Why we cannot use string in mixins?

2016-02-27 Thread sigod via Digitalmars-d-learn
On Saturday, 27 February 2016 at 23:43:07 UTC, cym13 wrote: Could you please provide a link to said comment? Maybe some context would help bring some sanity over this statement. Topic: https://www.reddit.com/r/programming/comments/30sqtd/why_didnt_the_d_language_become_mainstream_as/ Said

Re: How to detect if an array if dynamic or static

2016-02-25 Thread sigod via Digitalmars-d-learn
On Thursday, 25 February 2016 at 12:18:07 UTC, mahdi wrote: On Thursday, 25 February 2016 at 11:50:02 UTC, sigod wrote: On Thursday, 25 February 2016 at 10:03:08 UTC, mahdi wrote: Thanks. So when we define the function, we MUST specify the array size to be able to accept a static array?

Re: How to detect if an array if dynamic or static

2016-02-25 Thread sigod via Digitalmars-d-learn
On Thursday, 25 February 2016 at 12:18:07 UTC, mahdi wrote: On Thursday, 25 February 2016 at 11:50:02 UTC, sigod wrote: On Thursday, 25 February 2016 at 10:03:08 UTC, mahdi wrote: Thanks. So when we define the function, we MUST specify the array size to be able to accept a static array?

Re: How to detect if an array if dynamic or static

2016-02-25 Thread sigod via Digitalmars-d-learn
On Thursday, 25 February 2016 at 10:03:08 UTC, mahdi wrote: Thanks. So when we define the function, we MUST specify the array size to be able to accept a static array? Can't we just define a function which can accept any static array with any size? (e.g. a function to calculate average of a

Re: Simple performance question from a newcomer

2016-02-22 Thread sigod via Digitalmars-d-learn
On Sunday, 21 February 2016 at 16:20:30 UTC, bachmeier wrote: On Sunday, 21 February 2016 at 14:32:15 UTC, dextorious wrote: I had heard while reading up on the language that in D explicit loops are generally frowned upon and not necessary for the usual performance reasons. First, a minor

Re: Running task once a day in vibe.d

2016-02-16 Thread sigod via Digitalmars-d-learn
On Tuesday, 16 February 2016 at 18:30:43 UTC, Nick wrote: Hey folks I'm making a vibe.d application. Once a day it needs to download some data. How do i get the program to perform this task once a day? Regards, Nick You can use `Timer`. See `setTimer`/`createTimer` in

Re: Reserving capacity in associative arrays

2016-02-14 Thread sigod via Digitalmars-d-learn
On Monday, 15 February 2016 at 03:22:44 UTC, Jon D wrote: Is there a way to reserve capacity in associative arrays? In some programs I've been writing I've been getting reasonable performance up to about 10 million entries, but beyond that performance is impacted considerably (say, 30 million

Re: Non-English characters in code - "character 0x2212 is not a valid token"

2016-02-04 Thread sigod via Digitalmars-d-learn
On Thursday, 28 January 2016 at 14:45:36 UTC, Adam D. Ruppe wrote: On Thursday, 28 January 2016 at 14:39:46 UTC, sigod wrote: I tried to compile your code on dpaste (2.070.0) and got this: dpaste has an input mangling bug with some characters as a result of the form submission over the web.

Re: print function

2016-02-04 Thread sigod via Digitalmars-d-learn
On Thursday, 4 February 2016 at 00:23:07 UTC, ixid wrote: It would be nice to have a simple writeln that adds spaces automatically like Python's 'print' in std.stdio, perhaps called print. It seems Andrei decided to add such function:

Re: Get the return type of the function

2016-02-03 Thread sigod via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 19:21:06 UTC, Meta wrote: On Wednesday, 3 February 2016 at 18:40:27 UTC, xtreak wrote: Thanks. I was trying to get the return type of lambdas. I was trying the following and got an error. I was using dpaste with dmd 2.070 writeln(ReturnType!(a =(a *a)))

Re: Counting time difference.

2016-02-03 Thread sigod via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 22:27:07 UTC, holo wrote: When i start same program on server in different timezone difference is much higher (more than hour). Why it is happening? Timezones shouldnt have influence on such equation. Try using `Clock.currTime(UTC())`. And make sure all

Re: Non-English characters in code - "character 0x2212 is not a valid token"

2016-01-28 Thread sigod via Digitalmars-d-learn
On Thursday, 28 January 2016 at 13:26:27 UTC, Andrea Fontana wrote: On Thursday, 28 January 2016 at 13:18:55 UTC, pineapple wrote: I experimented with using the character 'ħ' in a variable name, and wasn't terribly surprised when the compiler didn't like it. What did surprise me is that I

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

2016-01-28 Thread sigod via Digitalmars-d-learn
On Thursday, 28 January 2016 at 13:36:46 UTC, Puming wrote: 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

splitter, compilation issue

2015-10-27 Thread sigod via Digitalmars-d-learn
Here's simple code: import std.algorithm; import std.array; import std.file; void main(string[] args) { auto t = args[1].readText() .splitter('\n') .filter!(e => e.length)

Re: splitter, compilation issue

2015-10-27 Thread sigod via Digitalmars-d-learn
Well, problem boils down to `splitter` having a greater constraints than most functions can meet. Thanks everyone for clarification. P.S. Maybe I should repost my question on SO? I really thought it was a bug, so I posted it here.

Re: splitter, compilation issue

2015-10-27 Thread sigod via Digitalmars-d-learn
On Tuesday, 27 October 2015 at 22:33:32 UTC, Adam D. Ruppe wrote: On Tuesday, 27 October 2015 at 22:18:55 UTC, sigod wrote: P.S. Maybe I should repost my question on SO? I really thought it was a bug, so I posted it here. You could, but I'd say the same thing there I don't expect different

Re: splitter, compilation issue

2015-10-27 Thread sigod via Digitalmars-d-learn
On Tuesday, 27 October 2015 at 21:54:33 UTC, Jonathan M Davis wrote: Well, split calls splitter, and it doesn't make much of an attempt to check its arguments in its template constraint, mostly passing the buck onto splitter, since it's really just a wrapper around splitter that calls array on

Re: splitter, compilation issue

2015-10-27 Thread sigod via Digitalmars-d-learn
On Tuesday, 27 October 2015 at 21:45:10 UTC, Ali Çehreli wrote: On 10/27/2015 01:58 PM, sigod wrote: Here's simple code: import std.algorithm; import std.array; import std.file; void main(string[] args) { auto t = args[1].readText()

Re: splitter, compilation issue

2015-10-27 Thread sigod via Digitalmars-d-learn
On Tuesday, 27 October 2015 at 22:56:07 UTC, sigod wrote: On Tuesday, 27 October 2015 at 22:33:32 UTC, Adam D. Ruppe wrote: On Tuesday, 27 October 2015 at 22:18:55 UTC, sigod wrote: P.S. Maybe I should repost my question on SO? I really thought it was a bug, so I posted it here. You could,

Re: Curl, how to recieve data.

2015-10-18 Thread sigod via Digitalmars-d-learn
On Sunday, 18 October 2015 at 21:01:05 UTC, holo wrote: On Sunday, 18 October 2015 at 20:12:42 UTC, sigod wrote: [...] I changed it to such code: ... auto client = HTTP(endpoint ~ "?" ~ canonicalQueryString); client.method = HTTP.Method.get;

Re: Curl, how to recieve data.

2015-10-18 Thread sigod via Digitalmars-d-learn
On Sunday, 18 October 2015 at 20:05:24 UTC, holo wrote: @sigod Actually im working on ec2 requests. Thank you for help, it is working right now. I don't know why i was trying "+=" before instead of "~=". Is it good solution to make it such way? Not really as it will trigger allocation on

Re: Curl, how to recieve data.

2015-10-18 Thread sigod via Digitalmars-d-learn
On Sunday, 18 October 2015 at 18:04:53 UTC, holo wrote: I'm trying to receive data from curl request my sample code looks like that: ... auto client = HTTP(endpoint ~ "?" ~ canonicalQueryString); client.method = HTTP.Method.get;

Re: Starting a HTTPS session with D

2015-08-18 Thread sigod via Digitalmars-d-learn
On Thursday, 12 February 2015 at 12:34:21 UTC, Vladimir Panteleev wrote: On Windows, if you are using the curl library included with DMD 2.066.1, curl will use the Windows certificate store. Did this changed? I use 2.068.0 and still have problems with SSL. Sorry for necroposting.

Re: Does D have syntax for adding subscopes to classes?

2015-08-12 Thread sigod via Digitalmars-d-learn
On Wednesday, 12 August 2015 at 15:21:28 UTC, GregoryP wrote: I'm just wondering if, or how much of the following is possible in some way in D: class Foo { int x; sub Bar { int x; int getFooX(){ return super.x; } sub FooBar { int x; int

Re: Code Reviewer

2015-08-12 Thread sigod via Digitalmars-d-learn
On Tuesday, 11 August 2015 at 22:50:52 UTC, Clayton wrote: Hello everyone, Am looking for someone who could help review my code . As an entry exercise to D am converting 3 C implementations of popular pattern matching algorithms. The idea is to have 6 final implementations ( 3 compile-time

Re: lambda syntax with curly braces

2015-08-10 Thread sigod via Digitalmars-d-learn
On Monday, 10 August 2015 at 16:02:31 UTC, bachmeier wrote: On Monday, 10 August 2015 at 15:05:55 UTC, sigod wrote: I see. But it's really counter intuitive after working with C#. Probably documentation should stress out the difference. Thanks, Adam. I assume you mean this page:

Re: lambda syntax with curly braces

2015-08-10 Thread sigod via Digitalmars-d-learn
On Monday, 10 August 2015 at 14:05:30 UTC, Adam D. Ruppe wrote: On Monday, 10 August 2015 at 13:57:50 UTC, sigod wrote: [...] It does exactly what that says: rewrites it to (a) { return { writeln(a); }; } which is returning a delegate. [...] So your code passed a delegate

Re: Concurrency Confusion

2015-08-10 Thread sigod via Digitalmars-d-learn
On Monday, 10 August 2015 at 22:21:18 UTC, 岩倉 澪 wrote: On Saturday, 8 August 2015 at 06:24:30 UTC, sigod wrote: Use negative value for `receiveTimeout`. http://stackoverflow.com/q/31616339/944911 actually this no longer appears to be true? Passing -1.msecs as the duration gives me an

Re: Concurrency Confusion

2015-08-10 Thread sigod via Digitalmars-d-learn
On Monday, 10 August 2015 at 22:21:18 UTC, 岩倉 澪 wrote: On Saturday, 8 August 2015 at 06:24:30 UTC, sigod wrote: Use negative value for `receiveTimeout`. http://stackoverflow.com/q/31616339/944911 actually this no longer appears to be true? Passing -1.msecs as the duration gives me an

Re: Concurrency Confusion

2015-08-10 Thread sigod via Digitalmars-d-learn
On Monday, 10 August 2015 at 22:21:18 UTC, 岩倉 澪 wrote: On Saturday, 8 August 2015 at 06:24:30 UTC, sigod wrote: Use negative value for `receiveTimeout`. http://stackoverflow.com/q/31616339/944911 actually this no longer appears to be true? Passing -1.msecs as the duration gives me an

Re: Concurrency Confusion

2015-08-10 Thread sigod via Digitalmars-d-learn
On Monday, 10 August 2015 at 22:31:33 UTC, sigod wrote: On Monday, 10 August 2015 at 22:21:18 UTC, 岩倉 澪 wrote: [...] It should be this line: https://github.com/D-Programming-Language/phobos/blob/master/std/concurrency.d#L1910 [...] This lines still there:

lambda syntax with curly braces

2015-08-10 Thread sigod via Digitalmars-d-learn
From docs: The following part = AssignExpression is rewritten to FunctionLiteralBody: { return AssignExpression ; } So, I wonder what happens when curly braces already in place? Consider this example: ``` import std.algorithm; import std.stdio; void main() { [1,2,3,4,5] .each!(a

Re: Concurrency Confusion

2015-08-08 Thread sigod via Digitalmars-d-learn
On Saturday, 8 August 2015 at 01:24:04 UTC, 岩倉 澪 wrote: On Saturday, 8 August 2015 at 00:39:57 UTC, 岩倉 澪 wrote: receiveTimeout(0.msecs, (immutable Bar[] bar){ baz = cast(Bar[])bar; }); Whoops, that should be: receiveTimeout(0.msecs,

Re: Calling Syntax (no, not UFCS)

2015-08-03 Thread sigod via Digitalmars-d-learn
On Monday, 3 August 2015 at 22:42:15 UTC, SirNickolas wrote: Hello! I'm new in D and it is amazing! Can you tell me please if it is discouraged or deprecated to call a function by just putting its name, without brackets? It's quite unusual for me (used C++ and Python before), but I can see

Re: std.algorithm each documentation terse

2015-07-20 Thread sigod via Digitalmars-d-learn
On Monday, 20 July 2015 at 14:40:59 UTC, jmh530 wrote: I have found the documentation for each in std.algorithm a bit terse. It seemed like it was an eager version of map, but it seems to be a bit more limited than that. Why are you trying to use `each` in place which belongs to `map`?

Re: Working functionally with third party libraries

2015-07-17 Thread sigod via Digitalmars-d-learn
On Friday, 17 July 2015 at 09:07:29 UTC, Jarl André Hübenthal wrote: But its pretty nice to know that there is laziness in D, but when I query mongo I expect all docs to be retrieved, since there are no paging in the underlying queries? Thus, having a lazy functionality on top of non lazy db

Re: Working functionally with third party libraries

2015-07-17 Thread sigod via Digitalmars-d-learn
On Friday, 17 July 2015 at 15:41:22 UTC, ZombineDev wrote: eager approach, since it's more straightforward. What makes you think it's always more straightforward? Sometimes (like in this case with MongoDB) you cannot write eager approach without first writing lazy one.

Re: incorrect data when returning static array in place of dynamic

2015-07-10 Thread sigod via Digitalmars-d-learn
On Monday, 6 July 2015 at 10:20:28 UTC, anonymous wrote: On Monday, 6 July 2015 at 07:48:17 UTC, sigod wrote: Aren't compiler smart enough to prevent it? ``` ubyte[] test1() { auto b = sha1Of(); return b; // Error: escaping reference to local b } ubyte[] test2() {

Re: incorrect data when returning static array in place of dynamic

2015-07-10 Thread sigod via Digitalmars-d-learn
On Monday, 6 July 2015 at 14:56:38 UTC, Marc Schütz wrote: On Monday, 6 July 2015 at 10:20:28 UTC, anonymous wrote: dmd 2.068.0 catches this. You can get the beta here: http://downloads.dlang.org/pre-releases/2.x/2.068.0/ ... and it already contains a std.digest.hmac module :-) Yes, thanks.

Re: incorrect data when returning static array in place of dynamic

2015-07-06 Thread sigod via Digitalmars-d-learn
On Monday, 6 July 2015 at 05:30:46 UTC, thedeemon wrote: On Sunday, 5 July 2015 at 18:57:46 UTC, sigod wrote: Why does function return incorrect data? Using `.dup` in return expression or using `ubyte[20]` as return type fixes problem, but why? Because sha1Of() returns ubyte[20], this is a

incorrect data when returning static array in place of dynamic

2015-07-05 Thread sigod via Digitalmars-d-learn
Consider this code: ``` import std.digest.digest; import std.stdio; ubyte[] hmac_sha1(const(ubyte)[] key, const(ubyte)[] message) { import std.digest.sha; enum block_size = 64; if (key.length block_size) key = sha1Of(key); if (key.length

Nullable with reference types

2015-06-30 Thread sigod via Digitalmars-d-learn
Hi, everyone. ``` import std.typecons : Nullable; class Test {} Nullable!Test test; assert(test.isNull); ``` Why does `Nullable` allowed to be used with reference types (e.g. classes)? P.S. I have experience with C#, where `NullableT` cannot be used with reference types. And it sounds

Re: Why D doesn't have an equivalent to C#'s readonly?

2015-06-30 Thread sigod via Digitalmars-d-learn
On Monday, 29 June 2015 at 20:12:12 UTC, Assembly wrote: I believe it's a design choice, if so, could someone explain why? is immutable better than C#'s readonly so that the readonly keyword isn't even needed? for example, I'd like to declare a member as readonly but I can't do it directly

Re: Why D doesn't have an equivalent to C#'s readonly?

2015-06-30 Thread sigod via Digitalmars-d-learn
On Monday, 29 June 2015 at 22:22:46 UTC, anonymous wrote: On Monday, 29 June 2015 at 22:11:16 UTC, sigod wrote: `new immutable(MyClass)()` is invalid code. It's perfectly fine, actually. Yes, you're right. It seems I've mistyped `immutable` when was checking it with compiler.

Re: cannot use UDA with same name as one of field's name

2015-06-24 Thread sigod via Digitalmars-d-learn
On Tuesday, 23 June 2015 at 23:52:52 UTC, Adam D. Ruppe wrote: On Tuesday, 23 June 2015 at 23:14:13 UTC, Steven Schveighoffer wrote: I'm not completely sure on the syntax, try adding some parens. Yeah, I'm pretty sure it needs to be @(full.name.here) void foo() Yep, something like this

Re: Check if template has been passed a reference type or value type?

2015-06-24 Thread sigod via Digitalmars-d-learn
On Sunday, 7 June 2015 at 15:39:17 UTC, Marc Schütz wrote: On Sunday, 7 June 2015 at 15:17:27 UTC, 1967 wrote: I've got a template that takes in a type. Sometimes the type is a class, sometimes a struct, sometimes just an int. It doesn't much matter what it is, but if it's a reference type I

cannot use UDA with same name as one of field's name

2015-06-23 Thread sigod via Digitalmars-d-learn
Hi. I have few questions about this piece of code. ``` import vibe.data.serialization; struct User { @name(_id) int id; // Error: function expected before (), not name of type string string name; } ``` Is it even proper compiler behavior? Is there any way to bypass it without using

Re: cannot use UDA with same name as one of field's name

2015-06-23 Thread sigod via Digitalmars-d-learn
On Tuesday, 23 June 2015 at 22:10:43 UTC, Steven Schveighoffer wrote: You can use @full.path.name ``` Error: unexpected ( in declarator Error: basic type expected, not _id Error: found '_id' when expecting ')' Error: no identifier for declarator .data.serialization.name(int) Error: semicolon

Re: Error: template cannot deduce function from argument types.

2014-08-24 Thread sigod via Digitalmars-d-learn
On Sunday, 24 August 2014 at 02:53:41 UTC, Damian Day wrote: isImplicitlyConvertible!(ElementType!R, T)) Try [ElementEncodingType][0]. [0]: http://dlang.org/phobos/std_range.html#ElementEncodingType

Re: Is this RDMD bug ?

2014-08-23 Thread sigod via Digitalmars-d-learn
On Saturday, 23 August 2014 at 16:28:46 UTC, novice2 wrote: I have 2 reduced files, wich i can't compile with new (DMD 2.066) rdmd.exe under Windows 7 32-bit. Command: rdmd --force --build-only aaa.d Message Error 42: Symbol Undefined _D3etc3bbb3fooFZi But command: dmd aaa.d etc\bbb.d Compile

Re: Is this RDMD bug ?

2014-08-23 Thread sigod via Digitalmars-d-learn
PR that introduced regression: https://github.com/D-Programming-Language/tools/pull/108

Re: Is this RDMD bug ?

2014-08-23 Thread sigod via Digitalmars-d-learn
On Saturday, 23 August 2014 at 17:32:15 UTC, Vladimir Panteleev wrote: No, it is not an rdmd bug. etc is a standard D package name reserved for Phobos, the standard library. It is the same for std and core. Please, point us directly to a documentation where it says that this words reserved.

Re: Is this RDMD bug ?

2014-08-23 Thread sigod via Digitalmars-d-learn
On Saturday, 23 August 2014 at 17:41:38 UTC, Dicebot wrote: On Saturday, 23 August 2014 at 17:37:39 UTC, sigod wrote: On Saturday, 23 August 2014 at 17:32:15 UTC, Vladimir Panteleev wrote: No, it is not an rdmd bug. etc is a standard D package name reserved for Phobos, the standard library.

Re: Is this RDMD bug ?

2014-08-23 Thread sigod via Digitalmars-d-learn
On Saturday, 23 August 2014 at 18:28:32 UTC, Vladimir Panteleev wrote: On Saturday, 23 August 2014 at 18:23:25 UTC, sigod wrote: Isn't it better to document such things? Yes. Please create a pull request. Easy to say. In my TODO list lies record to create PR for [this issue][0]. Today is

Re: private selective imports

2014-08-06 Thread sigod via Digitalmars-d-learn
On Wednesday, 6 August 2014 at 18:33:23 UTC, Dicebot wrote: Most voted DMD bug : https://issues.dlang.org/show_bug.cgi?id=314 +1 vote from me.

Re: unittest affects next unittest

2014-08-05 Thread sigod via Digitalmars-d-learn
On Saturday, 2 August 2014 at 06:46:04 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: On Fri, 01 Aug 2014 23:09:37 + sigod via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Code: http://dpaste.dzfl.pl/51bd62138854 (It was reduced by DustMite.) Have I missed

unittest affects next unittest

2014-08-01 Thread sigod via Digitalmars-d-learn
Code: http://dpaste.dzfl.pl/51bd62138854 (It was reduced by DustMite.) Have I missed something about structs? Or this simply a bug?

Re: fuction Return function

2014-07-26 Thread sigod via Digitalmars-d-learn
On Saturday, 26 July 2014 at 20:49:30 UTC, seany wrote: Can a function return a function in D? Sorry if i missed the answer somewhere Just alias your function signature: ```d alias MyFunctionType = void function(int); ``` Example from my own code: ```d alias DeserializeBody = TLObject

Re: mixin assembler does not work?

2014-07-21 Thread sigod via Digitalmars-d-learn
On Sunday, 20 July 2014 at 15:54:15 UTC, bearophile wrote: mixin template Vala2(uint count, alias arr) { What about disallowing mixin templatename unless you add mixin before the template keyword? Bye, bearophile I thought it's disallowed.

Re: Get folders in path

2014-07-15 Thread sigod via Digitalmars-d-learn
On Tuesday, 15 July 2014 at 08:31:10 UTC, pgtkda wrote: How can i get all folders from a given path? If I understood you correctly: http://dlang.org/phobos/std_file.html#.dirEntries

Re: std.algorithm.among

2014-07-13 Thread sigod via Digitalmars-d-learn
On Sunday, 13 July 2014 at 11:18:05 UTC, bearophile wrote: The idea of not making std.algorithm.among!() a predicate was not so good: void main() { import std.stdio, std.algorithm; auto s = hello how\nare you; s.until!(c = c.among!('\n', '\r')).writeln; } (A normal workaround is

Re: Concatenates int

2014-07-10 Thread sigod via Digitalmars-d-learn
On Thursday, 10 July 2014 at 17:30:17 UTC, Sean Campbell wrote: if I need to Concatenate ints I'l just use a recursive pow based on length int ConcatInt(int[] anint){ int total = 0; for(int i=0;ianint.length;i++){ total += anint[i]*10^^(anint.length-i-1);

Re: Using enum constant from different modules

2014-07-10 Thread sigod via Digitalmars-d-learn
On Thursday, 10 July 2014 at 20:59:17 UTC, simendsjo wrote: Strings behaves a bit odd with is(). The following passes: import std.stdio; void f(string a, string b) { assert(a is b); // also true } void main() { string a = aoeu; string b = aoeu; assert(a is b); // true f(a,

Re: SList: How do I use linearRemove?

2014-06-28 Thread sigod via Digitalmars-d-learn
On Thursday, 26 June 2014 at 16:50:38 UTC, Lemonfiend wrote: This doesn't (why?): auto s = SList!int(1, 2, 3, 4, 5); auto s2 = SList!int(1, 2, 3, 4, 5); auto r = s2[]; popFrontN(r, 1); auto r1 = s.linearRemove(r); This is intended behavior: https://issues.dlang.org/show_bug.cgi?id=12999

Re: import except one?

2014-06-26 Thread sigod via Digitalmars-d-learn
``` import std.process : Config_ = Config; ```

Re: import except one?

2014-06-26 Thread sigod via Digitalmars-d-learn
Sorry, wrong one. There seems no solution for this. So, you must use fully qualified name.

Re: SList: How do I use linearRemove?

2014-06-26 Thread sigod via Digitalmars-d-learn
Take a look at unittests in [std.container.slist][0]: ``` unittest { auto s = SList!int(1, 2, 3, 4, 5); auto r = s[]; popFrontN(r, 3); auto r1 = s.linearRemove(r); assert(s == SList!int(1, 2, 3)); assert(r1.empty); } unittest { auto s = SList!int(1, 2, 3, 4, 5, 6, 7,

Re: import except one?

2014-06-26 Thread sigod via Digitalmars-d-learn
Dirty solution: ``` import scriptlike; import your_module; import your_module : Config; ``` So, `Config` from your module will override one from scriptlike.

Re: SList: How do I use linearRemove?

2014-06-26 Thread sigod via Digitalmars-d-learn
First case is a bug. I'll make pull request. Not sure about second.

Re: mixin(__MODULE__) fails if module name is module

2014-06-24 Thread sigod via Digitalmars-d-learn
I opened new issue: https://issues.dlang.org/show_bug.cgi?id=12986

mixin(__MODULE__) fails if module name is module

2014-06-22 Thread sigod via Digitalmars-d-learn
E.g.: module.d: (or just `module module;` in source file) ``` import std.stdio; void main() { foreach (m; __traits(allMembers, mixin(__MODULE__))) { // module.d-mixin-4(4): Error: expression expected, not 'module' writeln(m); } } ``` Documentation says: Package names cannot

Re: mixin(__MODULE__) fails if module name is module

2014-06-22 Thread sigod via Digitalmars-d-learn
On Sunday, 22 June 2014 at 12:52:11 UTC, sigod wrote: module.d: (or just `module module;` in source file) I was wrong about `module module;` declaration.

Re: mixin(__MODULE__) fails if module name is module

2014-06-22 Thread sigod via Digitalmars-d-learn
This question seems more fit for the main D newsgroup. Should I create new thread in the main newsgroup? Look in Bugzilla if there is a enhancement request. Yeah. I found one: https://issues.dlang.org/show_bug.cgi?id=456

package reflection

2014-06-22 Thread sigod via Digitalmars-d-learn
In the video Case Studies In Simplifying Code With Compile-Time Reflection [was pointed out][0] that it is possible to reflect on imported packages. So, I tried: reflection.d: ``` import std.stdio; import test.module1; import test.module2; void main() { foreach (m;

Re: Doing exercise from book, but I'm getting error with splitter

2014-06-18 Thread sigod via Digitalmars-d-learn
On Monday, 16 June 2014 at 16:49:46 UTC, Andrew Brown wrote: ulong[string] dictionary; // the length property is ulong, not uint Actually length is size_t (uint on x86 and ulong on x64).

Re: hijacking override from template mixin

2014-06-14 Thread sigod via Digitalmars-d-learn
On Monday, 9 June 2014 at 15:54:21 UTC, Ivan Kazmenko wrote: I'd expect a multiple overrides of same function error, much like if I just paste the mixin code by hand. Is that a bug or working by design? In the latter case, please explain the reasoning. http://dlang.org/template-mixin.html

Re: __traits with alias

2014-05-08 Thread sigod via Digitalmars-d-learn
On Thursday, 8 May 2014 at 07:33:34 UTC, Philippe Sigaud via Digitalmars-d-learn wrote: A workaround is to wrap it into another template, to 'hide' __traits. Like this: alias Alias(alias a) = a; // A bit circular, I know. Oh, thank you. I think there is bug report / enhancement for this. I

Re: Down the VisualD0.3.38-1.exe ,found virus!

2014-05-08 Thread sigod via Digitalmars-d-learn
On Friday, 9 May 2014 at 01:02:39 UTC, FrankLike wrote: Hi,everyone, down VisulaD from http://rainers.github.io/visuald/visuald/StartPage.html found the virus:Win32.Troj.Undef.(kcloud) Why? Frank

__traits with alias

2014-05-07 Thread sigod via Digitalmars-d-learn
void registerAll(alias module_)() { foreach (m; __traits(derivedMembers, module_)) { regInner!(__traits(getMember, module_, m)); // compiles alias a = __traits(getMember, module_, m); // fails //Error: basic type expected, not __traits //Error: semicolon