Re: Why 16Mib static array size limit?

2016-08-16 Thread Yuxuan Shui via Digitalmars-d
On Tuesday, 16 August 2016 at 17:51:13 UTC, Johan Engelen wrote: On Tuesday, 16 August 2016 at 01:28:05 UTC, Ali Çehreli wrote: With ldc2, the best option is to go with a dynamic array ONLY IF you access the elements through the .ptr property. As seen in the last result, using the [] operator

Re: Why 16Mib static array size limit?

2016-08-16 Thread Yuxuan Shui via Digitalmars-d
On Tuesday, 16 August 2016 at 19:50:14 UTC, Yuxuan Shui wrote: On Tuesday, 16 August 2016 at 18:46:06 UTC, Ali Çehreli wrote: On 08/16/2016 10:51 AM, Johan Engelen wrote: > On Tuesday, 16 August 2016 at 01:28:05 UTC, Ali Çehreli > wrote: >> >> With ldc2, the best option is to go with a dynamic

Re: Why 16Mib static array size limit?

2016-08-16 Thread Yuxuan Shui via Digitalmars-d
On Tuesday, 16 August 2016 at 18:46:06 UTC, Ali Çehreli wrote: On 08/16/2016 10:51 AM, Johan Engelen wrote: > On Tuesday, 16 August 2016 at 01:28:05 UTC, Ali Çehreli wrote: >> >> With ldc2, the best option is to go with a dynamic array ONLY IF you >> access the elements through the .ptr property.

Re: Why 16Mib static array size limit?

2016-08-15 Thread Yuxuan Shui via Digitalmars-d
On Tuesday, 16 August 2016 at 01:28:05 UTC, Ali Çehreli wrote: On 08/15/2016 12:09 PM, Ali Çehreli wrote: [...] Could you please help me understand the following results, possibly by analyzing the produced assembly? [...] There seem to be two things at work here: 1) when not accessed via

Re: DIP1000: Scoped Pointers (Discussion)

2016-08-11 Thread Yuxuan Shui via Digitalmars-d
On Thursday, 11 August 2016 at 21:28:57 UTC, sclytrack wrote: On Wednesday, 10 August 2016 at 20:36:38 UTC, Dicebot wrote: http://forum.dlang.org/post/pqsiqmkxenrwxoruz...@forum.dlang.org The first DIP has just landed into the new queue. It is a proposal from language authors and thus it bypas

Re: How do I use the ScopedAllocator?

2016-08-02 Thread Yuxuan Shui via Digitalmars-d
On Thursday, 28 July 2016 at 11:48:40 UTC, Nick Treleaven wrote: On Monday, 25 July 2016 at 07:33:25 UTC, Yuxuan Shui wrote: Valgrind reports double free anyways. I think it's just the inaccuracy of the glibc double free detection. Please file a bug - thanks! https://issues.dlang.org/ I found

Re: How do I use the ScopedAllocator?

2016-07-25 Thread Yuxuan Shui via Digitalmars-d
On Sunday, 24 July 2016 at 20:48:55 UTC, Nick Treleaven wrote: On Friday, 22 July 2016 at 01:54:28 UTC, Yuxuan Shui wrote: auto b = alloc.makeArray!A(10, A(1)); auto c = alloc.makeArray!A(2, A(2)); I noticed (using dpaste) if you edit the 'b' line to only alloc

How do I use the ScopedAllocator?

2016-07-21 Thread Yuxuan Shui via Digitalmars-d
Is it OK to use makeArray with ScopedAllocator to allocate something with a destructor? Because the destructor is not called when ScopedAllocator goes out of scope. And if I manually call dispose, I get a double free error: struct A { int a; ~this() n

Re: I'd love to see DScript one day ...

2016-06-13 Thread Yuxuan Shui via Digitalmars-d
On Tuesday, 14 June 2016 at 00:55:52 UTC, Walter Bright wrote: On 6/13/2016 5:13 PM, H. S. Teoh via Digitalmars-d wrote: My *real* dream is for D (or some suitable subset thereof) to replace Javascript in browsers. But that's a very distant, if at all even possible, dream. :-D It's a great

Re: Template currying

2016-05-05 Thread Yuxuan Shui via Digitalmars-d
On Friday, 6 May 2016 at 06:30:27 UTC, Yuxuan Shui wrote: On Friday, 6 May 2016 at 06:26:14 UTC, Yuxuan Shui wrote: On Friday, 6 May 2016 at 06:18:22 UTC, Yuxuan Shui wrote: On Thursday, 5 May 2016 at 23:33:07 UTC, Yuxuan Shui wrote: [...] Wait, I just realized that this example works in

Re: Template currying

2016-05-05 Thread Yuxuan Shui via Digitalmars-d
On Friday, 6 May 2016 at 06:26:14 UTC, Yuxuan Shui wrote: On Friday, 6 May 2016 at 06:18:22 UTC, Yuxuan Shui wrote: On Thursday, 5 May 2016 at 23:33:07 UTC, Yuxuan Shui wrote: On Thursday, 5 May 2016 at 23:19:59 UTC, Yuxuan Shui wrote: [...] See this example: int a(alias f)(){return f(3

Re: Template currying

2016-05-05 Thread Yuxuan Shui via Digitalmars-d
On Friday, 6 May 2016 at 06:18:22 UTC, Yuxuan Shui wrote: On Thursday, 5 May 2016 at 23:33:07 UTC, Yuxuan Shui wrote: On Thursday, 5 May 2016 at 23:19:59 UTC, Yuxuan Shui wrote: [...] See this example: int a(alias f)(){return f(3);} int b(int z, T)(T c){return c;} void main() {

Re: Template currying

2016-05-05 Thread Yuxuan Shui via Digitalmars-d
On Thursday, 5 May 2016 at 23:33:07 UTC, Yuxuan Shui wrote: On Thursday, 5 May 2016 at 23:19:59 UTC, Yuxuan Shui wrote: On Thursday, 5 May 2016 at 23:12:40 UTC, Ed wrote: On Thursday, 5 May 2016 at 22:53:01 UTC, Yuxuan Shui wrote: [...] alias aa(T) = a!(1,T); aa!ubyte(2); Your alias declara

Re: Template currying

2016-05-05 Thread Yuxuan Shui via Digitalmars-d
On Thursday, 5 May 2016 at 23:46:59 UTC, Ed wrote: On Thursday, 5 May 2016 at 23:33:07 UTC, Yuxuan Shui wrote: It'd really nice if this just works, That's clear that you've never been stuck in the fat mud of imperative and OO programming styles. You don't realize (anymore ?) how lucky we are

Re: Template currying

2016-05-05 Thread Yuxuan Shui via Digitalmars-d
On Thursday, 5 May 2016 at 23:38:38 UTC, Ed wrote: On Thursday, 5 May 2016 at 23:19:59 UTC, Yuxuan Shui wrote: On Thursday, 5 May 2016 at 23:12:40 UTC, Ed wrote: On Thursday, 5 May 2016 at 22:53:01 UTC, Yuxuan Shui wrote: [...] alias aa(T) = a!(1,T); aa!ubyte(2); Your alias declaration is n

Re: Template currying

2016-05-05 Thread Yuxuan Shui via Digitalmars-d
On Thursday, 5 May 2016 at 23:19:59 UTC, Yuxuan Shui wrote: On Thursday, 5 May 2016 at 23:12:40 UTC, Ed wrote: On Thursday, 5 May 2016 at 22:53:01 UTC, Yuxuan Shui wrote: On Thursday, 5 May 2016 at 21:54:29 UTC, Ed wrote: On Thursday, 5 May 2016 at 20:17:08 UTC, Yuxuan Shui wrote: [...] It'

Re: Template currying

2016-05-05 Thread Yuxuan Shui via Digitalmars-d
On Thursday, 5 May 2016 at 23:12:40 UTC, Ed wrote: On Thursday, 5 May 2016 at 22:53:01 UTC, Yuxuan Shui wrote: On Thursday, 5 May 2016 at 21:54:29 UTC, Ed wrote: On Thursday, 5 May 2016 at 20:17:08 UTC, Yuxuan Shui wrote: [...] It's hard to help without a minimal working example (maybe some

Re: Template currying

2016-05-05 Thread Yuxuan Shui via Digitalmars-d
On Thursday, 5 May 2016 at 21:54:29 UTC, Ed wrote: On Thursday, 5 May 2016 at 20:17:08 UTC, Yuxuan Shui wrote: [...] It's hard to help without a minimal working example (maybe something with just the body). If you mean that "alias new_parser = Comb!(a, b);" generates an error maybe that's

Template currying

2016-05-05 Thread Yuxuan Shui via Digitalmars-d
So I was working on a parser combinator library, where the combinators take parsers as template argument. It works well until recently I decided to change the parsers so they would take Ranges instead of just strings. The combinator used to look like: template Comb(alias parser1, alias pa

Re: Can we check the arguments to format() at compile time?

2016-04-01 Thread Yuxuan Shui via Digitalmars-d
On Friday, 1 April 2016 at 23:26:14 UTC, Alex Parrill wrote: On Friday, 1 April 2016 at 21:25:46 UTC, Yuxuan Shui wrote: [...] Not as-is, because the format string is a runtime argument and not a compile-time constant. Consider: writefln(rand() >= 0.5 ? "%s" : "%d", 123); It's certain

Can we check the arguments to format() at compile time?

2016-04-01 Thread Yuxuan Shui via Digitalmars-d
Clang has this nice feature that it will warn you when you passed wrong arguments to printf: #include int main(){ long long u = 10; printf("%c", u); } clang something.c: something.c:4:15: warning: format specifies type 'int' but the argument has type 'long long' [-Wformat] W

Re: TypeInfo madness

2016-03-07 Thread Yuxuan Shui via Digitalmars-d
On Monday, 7 March 2016 at 08:49:36 UTC, Johan Engelen wrote: On Monday, 7 March 2016 at 01:47:53 UTC, Yuxuan Shui wrote: On Sunday, 6 March 2016 at 23:27:45 UTC, Adam D. Ruppe wrote: It is just a mistake that TypeInfo isn't immutable, in my opinion. ...though changing it would be a breaking

Re: TypeInfo madness

2016-03-06 Thread Yuxuan Shui via Digitalmars-d
On Sunday, 6 March 2016 at 23:27:45 UTC, Adam D. Ruppe wrote: It is just a mistake that TypeInfo isn't immutable, in my opinion. ...though changing it would be a breaking change, I think it would make sense to do it. Is there really anything relies on TypeInfo being mutable?

TypeInfo madness

2016-03-06 Thread Yuxuan Shui via Digitalmars-d
In D (tested with D 2.070), one is allowed to modify TypeInfo returned by typeid(). Here is an example how this "feature" can be used maliciously. class A{ } class C : A{ int a = 1234; } class B : A{ float b; }

Re: Why not use the address of the TypeInfo symbol as TypeInfo.toHash()?

2016-03-03 Thread Yuxuan Shui via Digitalmars-d
On Friday, 4 March 2016 at 00:42:28 UTC, Walter Bright wrote: On 3/3/2016 4:29 PM, Yuxuan Shui wrote: After linking each _DxxTypeInfo___initZ symbol should have a unique address, so why are we using hash of type name as TypeInfo.toHash()? I don't think this has anything to do with compactin

Why not use the address of the TypeInfo symbol as TypeInfo.toHash()?

2016-03-03 Thread Yuxuan Shui via Digitalmars-d
After linking each _DxxTypeInfo___initZ symbol should have a unique address, so why are we using hash of type name as TypeInfo.toHash()? I don't think this has anything to do with compacting GC. Is there something I'm missing?

Re: [OT] Some neat ideas from the Kotlin language

2016-02-22 Thread Yuxuan Shui via Digitalmars-d
On Monday, 22 February 2016 at 19:33:12 UTC, Ice Create Man wrote: On Thursday, 18 February 2016 at 23:33:45 UTC, Yuxuan Shui wrote: Just come across Kotlin today, and found some interesting ideas skimming through its tutorial: [...] Both those issues predate both Kotlin and Swift. C# has ha

Re: Poor memory allocation performance with a lot of threads on 36 core machine

2016-02-19 Thread Yuxuan Shui via Digitalmars-d
On Friday, 19 February 2016 at 08:29:00 UTC, Jonathan M Davis wrote: On Thursday, 18 February 2016 at 17:27:13 UTC, Chris Wright wrote: [...] Unfortunately, given how easy it is to cast between mutable, const, immutable, shared (and it's quite common to construct something as mutable and the

Re: [OT] Some neat ideas from the Kotlin language

2016-02-19 Thread Yuxuan Shui via Digitalmars-d
On Friday, 19 February 2016 at 12:16:49 UTC, Jacob Carlborg wrote: On 2016-02-19 00:33, Yuxuan Shui wrote: Just come across Kotlin today, and found some interesting ideas skimming through its tutorial: 1) Null check [snip] You can even do this: if (var == null) return; //You can us

[OT] Some neat ideas from the Kotlin language

2016-02-18 Thread Yuxuan Shui via Digitalmars-d
Just come across Kotlin today, and found some interesting ideas skimming through its tutorial: 1) Null check Kotlin has Optional types, suffixed with a '?'. Like 'Int?', same as in Swift. But instead of explicitly unwrapping them (e.g. var! in Swift, or var.unwrap() in Rust), Kotlin let you d

Re: Partially instantiated template as argument to alias parameter.

2015-11-04 Thread Yuxuan Shui via Digitalmars-d
On Wednesday, 4 November 2015 at 23:10:09 UTC, Vladimir Panteleev wrote: On Wednesday, 4 November 2015 at 23:07:42 UTC, Yuxuan Shui wrote: I think this is a reasonable use case: auto A(R, S)(R a,S b) {return a+b;} auto B(alias f)(){return f(1, 1.0);} void main{writeln(B!(A!int)());} Current

Partially instantiated template as argument to alias parameter.

2015-11-04 Thread Yuxuan Shui via Digitalmars-d
I think this is a reasonable use case: auto A(R, S)(R a,S b) {return a+b;} auto B(alias f)(){return f(1, 1.0);} void main{writeln(B!(A!int)());}

Re: Partially instantiated template as argument to alias parameter.

2015-11-04 Thread Yuxuan Shui via Digitalmars-d
On Wednesday, 4 November 2015 at 23:07:42 UTC, Yuxuan Shui wrote: I think this is a reasonable use case: auto A(R, S)(R a,S b) {return a+b;} auto B(alias f)(){return f(1, 1.0);} void main{writeln(B!(A!int)());} For now I have to explicitly write A like this: template A(R){auto A(S)(R a, S b

Re: What is the current status of D build systems?

2015-07-31 Thread Yuxuan Shui via Digitalmars-d
On Friday, 31 July 2015 at 22:40:25 UTC, Trent Forkert wrote: On Friday, 31 July 2015 at 00:13:42 UTC, Yuxuan Shui wrote: [...] Oh hey, that's me! [...] I've got a handful of work-in-progress changes I've yet to push publicly, and even more I've yet to commit. (Yes, I have weird work hab

Re: What is the current status of D build systems?

2015-07-30 Thread Yuxuan Shui via Digitalmars-d
On Friday, 31 July 2015 at 02:00:41 UTC, Mike Parker wrote: On Friday, 31 July 2015 at 00:13:42 UTC, Yuxuan Shui wrote: are there any other build systems I should look into? Premake [1] supports mixing languages in the same build script. It's not a build tool itself, but can generate makefi

What is the current status of D build systems?

2015-07-30 Thread Yuxuan Shui via Digitalmars-d
Hi, I'm working on a project that mixes both C and D code, and does code generation as well. I've been using a shell script to hack this together, since I can't figure out how to do this with dub. Now I'm looking for a proper build system for building this project. reggae (https://github.c

Re: Make objects.opEquals a template?

2015-07-13 Thread Yuxuan Shui via Digitalmars-d
On Monday, 13 July 2015 at 09:23:36 UTC, Jonathan M Davis wrote: On Monday, 13 July 2015 at 06:49:10 UTC, Yuxuan Shui wrote: [...] https://issues.dlang.org/show_bug.cgi?id=9769 In theory, the plan is to remove opEquals, opCmp, toString, and toHash from Object so that they no longer force a p

Re: Make objects.opEquals a template?

2015-07-13 Thread Yuxuan Shui via Digitalmars-d
On Monday, 13 July 2015 at 09:10:41 UTC, ketmar wrote: On Mon, 13 Jul 2015 06:49:09 +, Yuxuan Shui wrote: The main reason here is to use '==' in @safe code: class A { override @safe bool opEquals(Object o) { return cast(A)o !is null; } } @safe void main() {

Make objects.opEquals a template?

2015-07-12 Thread Yuxuan Shui via Digitalmars-d
The main reason here is to use '==' in @safe code: class A { override @safe bool opEquals(Object o) { return cast(A)o !is null; } } @safe void main() { A a = new A; A b = new A; a == b; } This doesn't compile in current D, because objects.o

Re: Deduce template arguments from return value?

2015-07-12 Thread Yuxuan Shui via Digitalmars-d
On Sunday, 12 July 2015 at 10:45:52 UTC, rsw0x wrote: On Sunday, 12 July 2015 at 09:13:03 UTC, Yuxuan Shui wrote: For example: import std.conv; T a(T)(int a) { return to!T(a); } void main(){ string x = a(2); } D is not able to deduce T. Can we make it possible to deduce templat

Deduce template arguments from return value?

2015-07-12 Thread Yuxuan Shui via Digitalmars-d
For example: import std.conv; T a(T)(int a) { return to!T(a); } void main(){ string x = a(2); } D is not able to deduce T. Can we make it possible to deduce template arguments from where the return value is assigned to? Rust is able to do this: fn main() { let a : Vec =

Re: Extend D's switch statement?

2015-07-08 Thread Yuxuan Shui via Digitalmars-d
On Wednesday, 8 July 2015 at 17:30:59 UTC, Timon Gehr wrote: On 07/08/2015 10:31 AM, Martin Nowak wrote: On Wednesday, 8 July 2015 at 07:15:27 UTC, Yuxuan Shui wrote: [...] Hardly anyone wants switch to be a better if-else ladder. https://issues.dlang.org/show_bug.cgi?id=5862 I don't think

Extend D's switch statement?

2015-07-08 Thread Yuxuan Shui via Digitalmars-d
I think it will be useful to extent switch statement to support any type that implements opEquals and opHash. Is there any technical difficulties to implement this?

Re: pure format

2015-07-01 Thread Yuxuan Shui via Digitalmars-d
On Thursday, 4 June 2015 at 18:27:16 UTC, Steven Schveighoffer wrote: On 6/4/15 2:08 PM, Ali Çehreli wrote: [...] That is a terrible excuse if that is what the issue is. I recalled Don discussing this, found these threads (they are old, maybe something has gotten better since then): http:/

Re: dmd -profile=gc

2015-06-26 Thread Yuxuan Shui via Digitalmars-d
On Sunday, 3 May 2015 at 21:11:58 UTC, Walter Bright wrote: Just merged in is a new compiler switch that instruments generated code to collect statistics on memory allocation usage and generates a report upon program termination. (Much like how -profile works.) This was based on a prototype A

Re: ReturnType and overloaded functions

2015-06-13 Thread Yuxuan Shui via Digitalmars-d
On Saturday, 13 June 2015 at 05:14:00 UTC, Kenji Hara wrote: 2015-06-13 9:29 GMT+09:00 Idan Arye via Digitalmars-d < digitalmars-d@puremagic.com>: On Friday, 12 June 2015 at 23:26:00 UTC, Yuxuan Shui wrote: When there are multiple overloaded functions, whose return type will I get when I use

Re: std.(experimental.)logger voting manager wanted

2015-06-12 Thread Yuxuan Shui via Digitalmars-d
On Friday, 12 June 2015 at 13:22:59 UTC, extrawurst wrote: On Friday, 12 June 2015 at 12:58:46 UTC, Robert burner Schadek wrote: std.(experimental.)logger has been in phobos for one release. The idea was to mature stuff in experimental for one release and then have a vote on inclusion into phob

ReturnType and overloaded functions

2015-06-12 Thread Yuxuan Shui via Digitalmars-d
When there are multiple overloaded functions, whose return type will I get when I use ReturnType? Is there a way I could choose a specific function by its parameter types?

Re: Two ideas for faster builds

2015-06-10 Thread Yuxuan Shui via Digitalmars-d
On Thursday, 11 June 2015 at 00:50:01 UTC, Andrei Alexandrescu wrote: https://issues.dlang.org/show_bug.cgi?id=14679 https://issues.dlang.org/show_bug.cgi?id=14680 Andrei As for the .di file, I believe Rust compiler store serialized AST in .a and .so. Is it possible that we do the same? And w

Scoped in a foreach loop.

2015-06-04 Thread Yuxuan Shui via Digitalmars-d
I tried something like this: foreach(e; scoped!SomeRangeType(args)) { } And my program segment faults. But this works: { auto x = scoped!SomeRangeType(args); foreach(e; x) { } } Shouldn't the range be alive until the end of the loop?

<    1   2