Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-06 Thread Saurabh Das via Digitalmars-d-learn
On Sunday, 7 February 2016 at 02:51:49 UTC, tsbockman wrote: On Sunday, 7 February 2016 at 02:11:15 UTC, Marco Leise wrote: I understand that. We just have a different perspective on the problem. Your priorities: - don't break what's not broken - .slice! lends on opSlice and should return by r

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-06 Thread tsbockman via Digitalmars-d-learn
On Sunday, 7 February 2016 at 02:51:49 UTC, tsbockman wrote: We should start a new thread in "General" to ask whether people care about the `ref`-ness of `Tuple` slices is really the deciding factor. I made a poll: http://forum.dlang.org/post/inswmiscuqirkhfql...@forum.dlang.org

Re: Things that keep D from evolving?

2016-02-06 Thread Marco Leise via Digitalmars-d-learn
Am Sat, 06 Feb 2016 23:18:59 + schrieb Ola Fosheim Grøstad : > Things that could speed up collection: > - drop destructors so you don't track dead objects Interesting, that would also finally force external resources off the GC heap and into deterministic release. That needs a solution to inh

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-06 Thread tsbockman via Digitalmars-d-learn
On Sunday, 7 February 2016 at 02:11:15 UTC, Marco Leise wrote: I understand that. We just have a different perspective on the problem. Your priorities: - don't break what's not broken - .slice! lends on opSlice and should return by ref My priorities: - type of .slice! should be as if construc

Re: Things that keep D from evolving?

2016-02-06 Thread Marco Leise via Digitalmars-d-learn
Am Sat, 06 Feb 2016 11:47:02 + schrieb Ola Fosheim Grøstad : > Of course, Swift does not aim for very high performance, but for > convenient application/gui development. And frankly JavaScript is > fast enough for that kind of programming. My code would not see much ref counting in performa

Re: Custom hash table key is const, how to call dtors?

2016-02-06 Thread Marco Leise via Digitalmars-d-learn
Am Sun, 07 Feb 2016 01:05:28 + schrieb cy : > On Saturday, 6 February 2016 at 03:57:16 UTC, Marco Leise wrote: > > > No, but they could have dtors because they contain malloc'd > > data. E.g. string literals that don't live on the GC heap. > > Character arrays allocated with glibc malloc ar

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-06 Thread tsbockman via Digitalmars-d-learn
On Sunday, 7 February 2016 at 02:11:15 UTC, Marco Leise wrote: Why do I insist on the return type? Because surprisingly simple code breaks if it doesn't match. Not everything can be covered by runtime conversions in D. It still took me a while to come up with something obvious: uint[T

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-06 Thread Marco Leise via Digitalmars-d-learn
Am Sat, 06 Feb 2016 11:02:37 + schrieb tsbockman : > On Saturday, 6 February 2016 at 08:47:01 UTC, Saurabh Das wrote: > > I think we should add a static assert to slice to ensure that > > the current implementation is not used in a case where the > > alignment doesn't match. This is better t

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-06 Thread Marco Leise via Digitalmars-d-learn
Am Sat, 06 Feb 2016 07:57:08 + schrieb tsbockman : > On Saturday, 6 February 2016 at 06:34:05 UTC, Marco Leise wrote: > > I don't want to sound dismissive, but when that thought came > > to my mind I considered it unacceptable that the type of > > Tuple!(int, bool, string).slice(1, 3) would be

Re: Custom hash table key is const, how to call dtors?

2016-02-06 Thread cy via Digitalmars-d-learn
On Saturday, 6 February 2016 at 03:57:16 UTC, Marco Leise wrote: No, but they could have dtors because they contain malloc'd data. E.g. string literals that don't live on the GC heap. Character arrays allocated with glibc malloc are immutable? News to me...

Re: Dynamic Ctors ?

2016-02-06 Thread Ali Çehreli via Digitalmars-d-learn
On 02/06/2016 10:05 AM, Voitech wrote: > create manually, constructor > for each of T... parameter types You can use string mixins (makeCtor and makeCtors): string makeCtor(T)() { import std.string : format; return format(q{ this (%s t) { import std.stdio : writefln

Re: Things that keep D from evolving?

2016-02-06 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Saturday, 6 February 2016 at 22:41:28 UTC, cy wrote: On Saturday, 6 February 2016 at 10:29:32 UTC, Ola Fosheim Grøstad wrote: This prevents fast GC: Pointers. Would it be possible to write a fast garbage collector that just didn't track any pointers? Just offer a head's up that if you use

Re: Detecting exception unwinding

2016-02-06 Thread cy via Digitalmars-d-learn
On Saturday, 6 February 2016 at 14:25:21 UTC, Ola Fosheim Grøstad wrote: See, even Python supports this. :-) And D supports the "with" statement in python, in the form of "scope()" statements. The D way is slightly less misleading too, as with somethingThatFails() as e: print(e) doesn't

Re: Things that keep D from evolving?

2016-02-06 Thread cy via Digitalmars-d-learn
On Saturday, 6 February 2016 at 10:29:32 UTC, Ola Fosheim Grøstad wrote: This prevents fast GC: Pointers. Would it be possible to write a fast garbage collector that just didn't track any pointers? Just offer a head's up that if you use "this collector" and pointers on collectable data, you'r

Re: What's going to replace std.stream?

2016-02-06 Thread cy via Digitalmars-d-learn
On Saturday, 6 February 2016 at 08:24:59 UTC, Jakob Ovrum wrote: foreach(chunk; File("path/to/file").byChunk(16 * 1024)) Ohh, cool so the streaming...ish logic is in std.stdio now. I thought that module was only for text output.

Re: Why can't compile time expressions do ___?

2016-02-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 6 February 2016 at 22:13:55 UTC, cy wrote: I'm not clear on why you aren't allowed to allocate memory with compile time execution You can... use the built-in new operator or arrays, etc. or why access to the filesystem is restricted. (Unless you pass -J/ I think?) CTFE is a "pu

Why can't compile time expressions do ___?

2016-02-06 Thread cy via Digitalmars-d-learn
I'm not clear on why you aren't allowed to allocate memory with compile time execution, or why access to the filesystem is restricted. (Unless you pass -J/ I think?)

Re: Dynamic Ctors ?

2016-02-06 Thread Voitech via Digitalmars-d-learn
On Saturday, 6 February 2016 at 18:05:05 UTC, Voitech wrote: Hi, i have a variadic args template, with a class inside something like: template foo(T...){ class Inner(){ ... ... } } Now i want to make Inner create or i will create manually, constructor for each of T... parameter types, b

Dynamic Ctors ?

2016-02-06 Thread Voitech via Digitalmars-d-learn
Hi, i have a variadic args template, with a class inside something like: template foo(T...){ class Inner(){ ... ... } } Now i want to make Inner create or i will create manually, constructor for each of T... parameter types, but don't know what is syntax for it. I found that there is po

Re: Things that keep D from evolving?

2016-02-06 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Saturday, 6 February 2016 at 17:46:48 UTC, rsw0x wrote: Might as well manually free and delete instead. Not really, this was used in Objective-C before ARC. But you can always move retain/release/borrow/unborrow into your own pointer struct like shared_ptr.

Re: Things that keep D from evolving?

2016-02-06 Thread rsw0x via Digitalmars-d-learn
On Saturday, 6 February 2016 at 17:46:48 UTC, rsw0x wrote: On Saturday, 6 February 2016 at 17:46:00 UTC, Ola Fosheim Grøstad wrote: On Saturday, 6 February 2016 at 17:38:30 UTC, rsw0x wrote: Can't be done with the root class because classes never trigger RAII outside of (deprecated) scope alloc

Re: Things that keep D from evolving?

2016-02-06 Thread rsw0x via Digitalmars-d-learn
On Saturday, 6 February 2016 at 17:46:00 UTC, Ola Fosheim Grøstad wrote: On Saturday, 6 February 2016 at 17:38:30 UTC, rsw0x wrote: Can't be done with the root class because classes never trigger RAII outside of (deprecated) scope allocations. Not sure what you mean. The class instance doesn't

Re: Things that keep D from evolving?

2016-02-06 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Saturday, 6 February 2016 at 17:38:30 UTC, rsw0x wrote: Can't be done with the root class because classes never trigger RAII outside of (deprecated) scope allocations. Not sure what you mean. The class instance doesn't have to trigger anything? You "retain(instance)" to increase the refco

Re: Things that keep D from evolving?

2016-02-06 Thread rsw0x via Digitalmars-d-learn
On Saturday, 6 February 2016 at 17:36:28 UTC, Ola Fosheim Grøstad wrote: On Saturday, 6 February 2016 at 17:22:03 UTC, Adam D. Ruppe wrote: On Saturday, 6 February 2016 at 11:15:06 UTC, Ola Fosheim Grøstad wrote: Nothing prevents you from creating your own reference counting mechanism. A stru

Re: Things that keep D from evolving?

2016-02-06 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Saturday, 6 February 2016 at 17:22:03 UTC, Adam D. Ruppe wrote: On Saturday, 6 February 2016 at 11:15:06 UTC, Ola Fosheim Grøstad wrote: Nothing prevents you from creating your own reference counting mechanism. A struct wrapper doesn't give the things you need to reliably handle inheritanc

Re: Things that keep D from evolving?

2016-02-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 6 February 2016 at 11:15:06 UTC, Ola Fosheim Grøstad wrote: Nothing prevents you from creating your own reference counting mechanism. A struct wrapper doesn't give the things you need to reliably handle inheritance. interface A {} interface B {} class C : A, B {} void use(RefCo

Re: foreach seems to work with opIndex()

2016-02-06 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Feb 06, 2016 at 03:11:22PM +, ZombineDev via Digitalmars-d-learn wrote: > On Saturday, 6 February 2016 at 15:02:16 UTC, H. S. Teoh wrote: > >On Sat, Feb 06, 2016 at 02:43:52PM +, Tofu Ninja via > >Digitalmars-d-learn wrote: > >>Foreach seems to work if there is an opIndex() with no

Re: Things that keep D from evolving?

2016-02-06 Thread ZombineDev via Digitalmars-d-learn
On Saturday, 6 February 2016 at 15:14:06 UTC, Kagamin wrote: On Saturday, 6 February 2016 at 08:07:42 UTC, NX wrote: What language semantics prevent precise Lack of resources. Precise GC needs to know which fields are pointers. Somebody must generate that map. AFAIK there was an experiment o

Re: Conflicting UDA

2016-02-06 Thread Márcio Martins via Digitalmars-d-learn
On Saturday, 6 February 2016 at 15:01:44 UTC, Marc Schütz wrote: On Saturday, 6 February 2016 at 13:36:32 UTC, Márcio Martins wrote: [...] `@(mylib.ignore)` should work. You could open an enhancement request to enable the paren-less syntax. Thanks, that does work indeed and is not that verb

Re: foreach seems to work with opIndex()

2016-02-06 Thread Tofu Ninja via Digitalmars-d-learn
On Saturday, 6 February 2016 at 15:02:16 UTC, H. S. Teoh wrote: Not really sure, but opIndex() with no arguments is supposed to be the current way of implement the [] slicing operator for user-defined types. I'm not sure when foreach started supporting that, but it's certainly a nice thing!

Re: Things that keep D from evolving?

2016-02-06 Thread Kagamin via Digitalmars-d-learn
On Saturday, 6 February 2016 at 08:07:42 UTC, NX wrote: What language semantics prevent precise Lack of resources. Precise GC needs to know which fields are pointers. Somebody must generate that map. AFAIK there was an experiment on that. fast GC Fast GC needs to be notified about pointe

Re: foreach seems to work with opIndex()

2016-02-06 Thread ZombineDev via Digitalmars-d-learn
On Saturday, 6 February 2016 at 15:02:16 UTC, H. S. Teoh wrote: On Sat, Feb 06, 2016 at 02:43:52PM +, Tofu Ninja via Digitalmars-d-learn wrote: Foreach seems to work if there is an opIndex() with no arguments that returns a range interface, is this documented? I can't seem to find anything

Re: foreach seems to work with opIndex()

2016-02-06 Thread anonymous via Digitalmars-d-learn
On 06.02.2016 16:00, anonymous wrote: https://issues.dlang.org/show_bug.cgi?id=14619 Sorry, posted a bit hastily. Issue 14619 is just about a bug in the feature. The more relevant issue is number 5605: https://issues.dlang.org/show_bug.cgi?id=5605 As far as I can tell, this is not documente

Re: foreach seems to work with opIndex()

2016-02-06 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Feb 06, 2016 at 02:43:52PM +, Tofu Ninja via Digitalmars-d-learn wrote: > Foreach seems to work if there is an opIndex() with no arguments that > returns a range interface, is this documented? I can't seem to find > anything that say this is supposed to happen. I am not really > compla

Re: foreach seems to work with opIndex()

2016-02-06 Thread anonymous via Digitalmars-d-learn
On 06.02.2016 15:43, Tofu Ninja wrote: Foreach seems to work if there is an opIndex() with no arguments that returns a range interface, is this documented? I can't seem to find anything that say this is supposed to happen. I am not really complaining, its nice, but I just didnt really expect it b

Re: Conflicting UDA

2016-02-06 Thread Marc Schütz via Digitalmars-d-learn
On Saturday, 6 February 2016 at 13:36:32 UTC, Márcio Martins wrote: I came across an issue with UDAs and was wondering if there really is no way or if I just missed something... Basically, my library has an @ignore UDA, which conflicts with vibe.d's vibe.data.serialization. If both mine and

Re: Bug or intended?

2016-02-06 Thread Kagamin via Digitalmars-d-learn
I'd say support for this scenario is not implemented yet.

Re: foreach seems to work with opIndex()

2016-02-06 Thread Tofu Ninja via Digitalmars-d-learn
On Saturday, 6 February 2016 at 14:43:52 UTC, Tofu Ninja wrote: Foreach seems to work if there is an opIndex() with no arguments that returns a range interface, is this documented? I can't seem to find anything that say this is supposed to happen. I am not really complaining, its nice, but I ju

foreach seems to work with opIndex()

2016-02-06 Thread Tofu Ninja via Digitalmars-d-learn
Foreach seems to work if there is an opIndex() with no arguments that returns a range interface, is this documented? I can't seem to find anything that say this is supposed to happen. I am not really complaining, its nice, but I just didnt really expect it because I feel like I remember this be

Re: Overloading free functions & run-time dispatch based on parameter types

2016-02-06 Thread Marc Schütz via Digitalmars-d-learn
On Friday, 5 February 2016 at 19:48:45 UTC, Robert M. Münch wrote: I thought about it too, but I need it to work with more then one parameter, so I tried this which doesn't work: Value nativePlus(Value a, Value b){ // @@ not working, runtime exception castSwitch!( (IntV a) { castS

Re: Detecting exception unwinding

2016-02-06 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Saturday, 6 February 2016 at 06:08:41 UTC, cy wrote: Sorry, years of python programming have made me shy of destructors. It just looks a little less "magic" to me if I specify the destruction explicitly after creating the object, using the "scope(exit)" syntax. That is error-prone! In Pyt

Bug or intended?

2016-02-06 Thread rsw0x via Digitalmars-d-learn
I was playing around with alias templates and came across this, I reduced it to: --- struct A(alias C c){ auto foo(){ return c.i; } } struct B{ C c; A!c a; } struct C{ int i; } --- It gives me a "need 'this' for 'i' of type 'int'" error.

Conflicting UDA

2016-02-06 Thread Márcio Martins via Digitalmars-d-learn
I came across an issue with UDAs and was wondering if there really is no way or if I just missed something... Basically, my library has an @ignore UDA, which conflicts with vibe.d's vibe.data.serialization. If both mine and vibe's module are imported, DMD will fail with a very non-descriptiv

Re: Things that keep D from evolving?

2016-02-06 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Saturday, 6 February 2016 at 11:33:05 UTC, rsw0x wrote: On Saturday, 6 February 2016 at 11:15:06 UTC, Ola Fosheim Grøstad wrote: reference counting is incredibly slow, DIP74 attempts to partially amend that in D as it can't be done any other way besides compiler help. IIRC, it essentially ju

Re: Things that keep D from evolving?

2016-02-06 Thread rsw0x via Digitalmars-d-learn
On Saturday, 6 February 2016 at 11:15:06 UTC, Ola Fosheim Grøstad wrote: On Saturday, 6 February 2016 at 11:09:28 UTC, NX wrote: On Saturday, 6 February 2016 at 10:29:32 UTC, Ola Fosheim Grøstad wrote: What makes it impossible to have ref counted classes? Nothing. Then why do we need DIP74

Re: Things that keep D from evolving?

2016-02-06 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Saturday, 6 February 2016 at 11:09:28 UTC, NX wrote: On Saturday, 6 February 2016 at 10:29:32 UTC, Ola Fosheim Grøstad wrote: What makes it impossible to have ref counted classes? Nothing. Then why do we need DIP74 ? I think they aim for compiler optimizations, like ARC on Swift. But A

Re: Things that keep D from evolving?

2016-02-06 Thread NX via Digitalmars-d-learn
On Saturday, 6 February 2016 at 10:29:32 UTC, Ola Fosheim Grøstad wrote: What makes it impossible to have ref counted classes? Nothing. Then why do we need DIP74 ? And why documentation says RefCounted doesn't work with classes?

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-06 Thread tsbockman via Digitalmars-d-learn
On Saturday, 6 February 2016 at 08:47:01 UTC, Saurabh Das wrote: I think we should add a static assert to slice to ensure that the current implementation is not used in a case where the alignment doesn't match. This is better than failing without any warning. If we pursue the deprecation rout

Re: Things that keep D from evolving?

2016-02-06 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Saturday, 6 February 2016 at 08:07:42 UTC, NX wrote: What language semantics prevent precise & fast GC implementations? This prevents fast GC: Pointers. This prevents precise GC: internal Pointers + FFI. Go now has <10ms latency for small heaps, <20ms latency for up to 100GB heaps and <40

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-06 Thread Saurabh Das via Digitalmars-d-learn
On Saturday, 6 February 2016 at 08:01:20 UTC, tsbockman wrote: On Saturday, 6 February 2016 at 06:34:05 UTC, Marco Leise wrote: [...] I should also point out that, since there is no way to actually find out whether anyone is using the `ref`-ness of the return type in the wild, the approach t

Re: What's going to replace std.stream?

2016-02-06 Thread Jakob Ovrum via Digitalmars-d-learn
On Saturday, 6 February 2016 at 06:29:56 UTC, cy wrote: Let's say I have a socket, and a file, and I want to send the contents of that file to the socket. What's the best way to do that? Yes I'm aware that in Linux, you can use a combination of a pipe and splice(2) to keep all buffers kernel si

Things that keep D from evolving?

2016-02-06 Thread NX via Digitalmars-d-learn
So I came here to ask about things that prevent D to become better. What language semantics prevent precise & fast GC implementations? What makes it impossible to have ref counted classes? What are some other technical / design problems you encountered? (other than poor implementation and lac

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-06 Thread tsbockman via Digitalmars-d-learn
On Saturday, 6 February 2016 at 06:34:05 UTC, Marco Leise wrote: [...] I should also point out that, since there is no way to actually find out whether anyone is using the `ref`-ness of the return type in the wild, the approach that you and Saurabh Das are taking really ought to include chan

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-06 Thread tsbockman via Digitalmars-d-learn
On Saturday, 6 February 2016 at 06:34:05 UTC, Marco Leise wrote: I don't want to sound dismissive, but when that thought came to my mind I considered it unacceptable that the type of Tuple!(int, bool, string).slice(1, 3) would be something different than Tuple!(bool, string). In your case Tuple!(