Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Don
Steven Schveighoffer wrote: On Sat, 18 Apr 2009 14:05:30 -0400, Andrei Alexandrescu wrote: Steven Schveighoffer wrote: I gave this a lot of thought, and I think here is a possible solution: the main reason I'm hesitant on this idea is because of code like this: class X { auto opDotExp(st

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Yigal Chripun
On 19/04/2009 01:22, BCS wrote: Hello Yigal, On 18/04/2009 21:16, Andrei Alexandrescu wrote: In the syntax a.b how would either of a and b be identified at runtime? I mean, you write the code somewhere and it gets compiled. It's not like you're reading "a.b" from the console and then call s

Re: GC object finalization not guaranteed

2009-04-18 Thread Don
Leandro Lucarella wrote: Don, el 18 de abril a las 23:43 me escribiste: I don't understand why D even has finalizers. Can they do anything useful? Yes. I use them to manage GPU memory/resources. Another are wrapper classes around manually allocated arrays (to avoid the false pointer problem with

Re: Arbitrary sized Variant

2009-04-18 Thread Andrei Alexandrescu
dsimcha wrote: I've started looking at implementing arbitrary sized Variant, and I've hit a point where I need some opinions. The idea of arbitrary sized Variant is to heap allocate when things get too big to be stored inline in the VariantN struct. However, how should copying a VariantN struct

Re: D2 weak references

2009-04-18 Thread Jason House
Jason House wrote: > Tango's GC (and therefore > druntime's GC) has an explicit notification mechanism. I guess I shouldn't have assumed that the features of tango became part of druntime. I don't see any notification mechanism :( The best design I've come up with is to make a helper class we

Arbitrary sized Variant

2009-04-18 Thread dsimcha
I've started looking at implementing arbitrary sized Variant, and I've hit a point where I need some opinions. The idea of arbitrary sized Variant is to heap allocate when things get too big to be stored inline in the VariantN struct. However, how should copying a VariantN struct with the content

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Georg Wrede
Walter Bright wrote: A simple command line spell checker would be a cool demonstration of this! $ man bash /cdspell If set, minor errors in the spelling of a directory com- ponent in a cd command will be corrected. The errors checked for are transposed characters, a missing charac-

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread BCS
Hello Michel, On 2009-04-18 17:48:33 -0400, Andrei Alexandrescu said: Michel Fortin wrote: On 2009-04-18 11:19:38 -0400, Andrei Alexandrescu said: I'm confused. Isn't it clear that at the moment we "have" the ability to pass a function name as a runtime string? Indeed, you can pass the

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread BCS
Hello Adam, On Sat, Apr 18, 2009 at 06:10:27PM -0700, Andrei Alexandrescu wrote: The point of using "." is not syntactic convenience as much as the ability of the Dynamic structure to work out of the box with algorithms that use the standard notation. What if the dot remained exactly like it

Re: Why Java Doesn't Need Operator Overloading (and Very Few Languages Do, Really)

2009-04-18 Thread Andrei Alexandrescu
grauzone wrote: This has happened before. Somehow Java has this penchant for attracting odd groupies. Pretty much every feature that Java didn't have was vilified by zealots until adoption, when all of a sudden it became a brilliant decision. D has this too. Probably a lot of language enthu

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Andrei Alexandrescu
Michel Fortin wrote: On 2009-04-18 17:48:33 -0400, Andrei Alexandrescu said: Michel Fortin wrote: On 2009-04-18 11:19:38 -0400, Andrei Alexandrescu said: I'm confused. Isn't it clear that at the moment we "have" the ability to pass a function name as a runtime string? Indeed, you can p

Re: GC object finalization not guaranteed

2009-04-18 Thread Christopher Wright
Walter Bright wrote: Leandro Lucarella wrote: You missed the point. I'm not talking about freeing the memory. I'm talking about finalizers. A finalizer could send a "bye" packet throgh the net. That can't be handled by the OS. That shouldn't be handled by a finalizer. A "bye" packet can be h

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Steven Schveighoffer
On Sat, 18 Apr 2009 21:10:27 -0400, Andrei Alexandrescu wrote: Adam Burton wrote: Andrei Alexandrescu wrote: What about using something like '->' for dynamic calls instead of '.'? That's absolutely useless. If I have to write anything different from "." I might as well write "bloodyMaryBlo

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Steven Schveighoffer
On Sat, 18 Apr 2009 14:05:30 -0400, Andrei Alexandrescu wrote: Steven Schveighoffer wrote: I gave this a lot of thought, and I think here is a possible solution: the main reason I'm hesitant on this idea is because of code like this: class X { auto opDotExp(string fname, T...)(T args)

Re: Why Java Doesn't Need Operator Overloading (and Very Few Languages Do, Really)

2009-04-18 Thread grauzone
This has happened before. Somehow Java has this penchant for attracting odd groupies. Pretty much every feature that Java didn't have was vilified by zealots until adoption, when all of a sudden it became a brilliant decision. D has this too.

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Michel Fortin
On 2009-04-18 17:48:33 -0400, Andrei Alexandrescu said: Michel Fortin wrote: On 2009-04-18 11:19:38 -0400, Andrei Alexandrescu said: I'm confused. Isn't it clear that at the moment we "have" the ability to pass a function name as a runtime string? Indeed, you can pass the template argum

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Adam D. Ruppe
On Sat, Apr 18, 2009 at 06:10:27PM -0700, Andrei Alexandrescu wrote: > The point of using "." is not syntactic convenience as much as the > ability of the Dynamic structure to work out of the box with algorithms > that use the standard notation. What if the dot remained exactly like it is now an

Re: Why Java Doesn't Need Operator Overloading (and Very Few Languages Do, Really)

2009-04-18 Thread Andrei Alexandrescu
Edward Diener wrote: Paul D. Anderson wrote: Sounds like someone needs a strong dose of D!! http://java.dzone.com/articles/why-java-doesnt-need-operator The comments bounce between "operator overloading is always bad because you can do idiotic things with it" and "operator overloading is ess

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Andrei Alexandrescu
Adam Burton wrote: Andrei Alexandrescu wrote: What about using something like '->' for dynamic calls instead of '.'? That's absolutely useless. If I have to write anything different from "." I might as well write "bloodyMaryBloodyMaryBloodyMary". Andrei You could even write 'noodles' but that

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Walter Bright
A simple command line spell checker would be a cool demonstration of this!

Re: GC object finalization not guaranteed

2009-04-18 Thread Walter Bright
Leandro Lucarella wrote: You missed the point. I'm not talking about freeing the memory. I'm talking about finalizers. A finalizer could send a "bye" packet throgh the net. That can't be handled by the OS. That shouldn't be handled by a finalizer. A "bye" packet can be handled by a static dest

Re: GC object finalization not guaranteed

2009-04-18 Thread Jason House
Walter Bright Wrote: > Leandro Lucarella wrote: > > Close a connection gracefully for example, I guess (I mean, send a "bye" > > packed, not just close the socket abruptly). Same for closing files > > writing some mark or something. They can be risky when finalization is not > > deterministic thou

Re: GC object finalization not guaranteed

2009-04-18 Thread Unknown W. Brackets
Well, I guess it would be doable to guarantee destruction, but *only* if order of destruction was not guaranteed. In other words, at the end, the GC would not scan, it would just destroy. Scanning is a problem, due to cycles and various other things, but destroying all roots would be potentia

Re: GC object finalization not guaranteed

2009-04-18 Thread Leandro Lucarella
Unknown W. Brackets, el 18 de abril a las 16:16 me escribiste: > The simple solution is this: > > 1. If your class object only involves memory, freed OS handles, etc., it > should be used as-is. This is most class objects. Destructors are > needed to clamp resource use (see File class.) A File

Re: Why Java Doesn't Need Operator Overloading (and Very Few Languages Do, Really)

2009-04-18 Thread Edward Diener
Paul D. Anderson wrote: Sounds like someone needs a strong dose of D!! http://java.dzone.com/articles/why-java-doesnt-need-operator The comments bounce between "operator overloading is always bad because you can do idiotic things with it" and "operator overloading is essential because sometime

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Adam Burton
Andrei Alexandrescu wrote: > Adam Burton wrote: >> Jason House wrote: >> >>> Andrei Alexandrescu Wrote: >>> Nick Sabalausky wrote: > Please do not accuse me of such a thing simply because I haven't > changed my opinion. You've held your ground as well, so I could just > as easily

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Christopher Wright
bearophile wrote: Andrei Alexandrescu: Yes. The amount of confusion in this thread is staggering. I think I have misunderstood about the whole thread then. If the string isn't determined at run time, then this thing isn't useful for my purposes, and it's not close to the object-C as I was ta

Re: GC object finalization not guaranteed

2009-04-18 Thread Unknown W. Brackets
The simple solution is this: 1. If your class object only involves memory, freed OS handles, etc., it should be used as-is. This is most class objects. Destructors are needed to clamp resource use (see File class.) 2. If your class object involves hardware handles, transactional assurance,

Re: GC object finalization not guaranteed

2009-04-18 Thread Leandro Lucarella
Leandro Lucarella, el 18 de abril a las 19:36 me escribiste: > Rainer Deyke, el 18 de abril a las 16:18 me escribiste: > > Leandro Lucarella wrote: > > > You missed the point. I'm not talking about freeing the memory. I'm > > > talking about finalizers. A finalizer could send a "bye" packet throgh

Re: GC object finalization not guaranteed

2009-04-18 Thread Leandro Lucarella
Rainer Deyke, el 18 de abril a las 16:18 me escribiste: > Leandro Lucarella wrote: > > You missed the point. I'm not talking about freeing the memory. I'm > > talking about finalizers. A finalizer could send a "bye" packet throgh the > > net. That can't be handled by the OS. > > It can't be handle

Re: GC object finalization not guaranteed

2009-04-18 Thread Leandro Lucarella
Don, el 18 de abril a las 23:43 me escribiste: > >>I don't understand why D even has finalizers. Can they do anything useful? > >Yes. I use them to manage GPU memory/resources. Another are wrapper classes > >around manually allocated arrays (to avoid the false pointer problem with > >very > >lar

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Simen Kjaeraas
Yigal Chripun wrote: what prevents D from having an eval function? suppose someone modifies the DMD front-end to compile a string with the source code of a function in-memory, than this is processed by something based on DDL and what you get is an API call that takes source code in a strin

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread BCS
Hello Yigal, On 18/04/2009 21:16, Andrei Alexandrescu wrote: In the syntax a.b how would either of a and b be identified at runtime? I mean, you write the code somewhere and it gets compiled. It's not like you're reading "a.b" from the console and then call some eval() function against them.

Re: GC object finalization not guaranteed

2009-04-18 Thread Leandro Lucarella
Fawzi Mohamed, el 18 de abril a las 23:41 me escribiste: > >>when the main thread ends other threads might be running, and removing > >>memory they are using is not necessarily a good idea. > >Then I guess gc_term() should be invoked when all threads have terminated. > >Is there any technical diffi

Re: GC object finalization not guaranteed

2009-04-18 Thread Rainer Deyke
Leandro Lucarella wrote: > You missed the point. I'm not talking about freeing the memory. I'm > talking about finalizers. A finalizer could send a "bye" packet throgh the > net. That can't be handled by the OS. It can't be handled by the GC either, because: - This would require a high-level wra

Re: GC object finalization not guaranteed

2009-04-18 Thread Leandro Lucarella
Fawzi Mohamed, el 18 de abril a las 23:43 me escribiste: > >If thread_joinAll() is called before gc_term(), I can't see how a thread > >could be still running when gc_term() is called. So, in terms of threads, > >I don't see a problem here. > > daemon theads are not joined So, you can keep thread

Re: Second parameter with ranges

2009-04-18 Thread Andrei Alexandrescu
dsimcha wrote: How do you do something like the following with ranges? auto foo = someRange([1U, 2, 3, 4, 5]); foreach(index, elem; foo) { writeln(index, " ", elem); } Has this been addressed yet? No :o(. Andrei

Re: GC object finalization not guaranteed

2009-04-18 Thread Leandro Lucarella
Walter Bright, el 18 de abril a las 14:34 me escribiste: > Leandro Lucarella wrote: > >Close a connection gracefully for example, I guess (I mean, send a "bye" > >packed, not just close the socket abruptly). Same for closing files > >writing some mark or something. They can be risky when finalizati

Re: GC object finalization not guaranteed

2009-04-18 Thread Leandro Lucarella
Walter Bright, el 18 de abril a las 14:33 me escribiste: > Leandro Lucarella wrote: > >The current GC implementation don't call finalizers for data that's still > >reference when the program *ended* (this is allowed by the specs, so it's > >fine, the question is why it's allowed by the specs). > >

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Andrei Alexandrescu
davidl wrote: 在 Sun, 19 Apr 2009 03:15:02 +0800,Daniel Keep 写道: Andrei Alexandrescu wrote: Michel Fortin wrote: ... Andrei, I think you, and perhaps everyone here, are overlooking one small but important detail. opDotExp, if a template like you're adovcating, undermines future runtime d

Second parameter with ranges

2009-04-18 Thread dsimcha
How do you do something like the following with ranges? auto foo = someRange([1U, 2, 3, 4, 5]); foreach(index, elem; foo) { writeln(index, " ", elem); } Has this been addressed yet?

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Andrei Alexandrescu
Adam Burton wrote: Jason House wrote: Andrei Alexandrescu Wrote: Nick Sabalausky wrote: Please do not accuse me of such a thing simply because I haven't changed my opinion. You've held your ground as well, so I could just as easily accuse you of being closed-minded and merely reaffirming a y

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Andrei Alexandrescu
Yigal Chripun wrote: On 18/04/2009 21:16, Andrei Alexandrescu wrote: bearophile wrote: Andrei Alexandrescu: Yes. The amount of confusion in this thread is staggering. I think I have misunderstood about the whole thread then. If the string isn't determined at run time, then this thing isn't u

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Andrei Alexandrescu
Michel Fortin wrote: On 2009-04-18 11:19:38 -0400, Andrei Alexandrescu said: I'm confused. Isn't it clear that at the moment we "have" the ability to pass a function name as a runtime string? Indeed, you can pass the template argument as a runtime argument to another function. No misunders

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Andrei Alexandrescu
davidl wrote: 在 Sun, 19 Apr 2009 02:16:30 +0800,Andrei Alexandrescu 写道: bearophile wrote: Andrei Alexandrescu: Yes. The amount of confusion in this thread is staggering. I think I have misunderstood about the whole thread then. If the string isn't determined at run time, then this thing i

Re: GC object finalization not guaranteed

2009-04-18 Thread Don
Robert Jacques wrote: On Sat, 18 Apr 2009 16:25:32 -0400, Don wrote: Leandro Lucarella wrote: Robert Jacques, el 18 de abril a las 11:56 me escribiste: On Sat, 18 Apr 2009 11:24:14 -0400, Leandro Lucarella wrote: I've just found out[1] this[2]: The garbage collector is not guaranteed

Re: GC object finalization not guaranteed

2009-04-18 Thread Fawzi Mohamed
On 2009-04-18 23:22:21 +0200, Leandro Lucarella said: Leandro Lucarella, el 18 de abril a las 18:03 me escribiste: Fawzi Mohamed, el 18 de abril a las 22:48 me escribiste: On 2009-04-18 22:25:32 +0200, Don said: Leandro Lucarella wrote: Robert Jacques, el 18 de abril a las 11:56 me escrib

Re: GC object finalization not guaranteed

2009-04-18 Thread Fawzi Mohamed
On 2009-04-18 23:03:11 +0200, Leandro Lucarella said: Fawzi Mohamed, el 18 de abril a las 22:48 me escribiste: On 2009-04-18 22:25:32 +0200, Don said: Leandro Lucarella wrote: Robert Jacques, el 18 de abril a las 11:56 me escribiste: On Sat, 18 Apr 2009 11:24:14 -0400, Leandro Lucarella

Re: GC object finalization not guaranteed

2009-04-18 Thread Walter Bright
Leandro Lucarella wrote: Close a connection gracefully for example, I guess (I mean, send a "bye" packed, not just close the socket abruptly). Same for closing files writing some mark or something. They can be risky when finalization is not deterministic though. Scoped objects should be used fo

Re: GC object finalization not guaranteed

2009-04-18 Thread Walter Bright
Leandro Lucarella wrote: The current GC implementation don't call finalizers for data that's still reference when the program *ended* (this is allowed by the specs, so it's fine, the question is why it's allowed by the specs). The why is because of speed. What's the point of running a gc pause

Re: GC object finalization not guaranteed

2009-04-18 Thread Leandro Lucarella
Leandro Lucarella, el 18 de abril a las 18:03 me escribiste: > Fawzi Mohamed, el 18 de abril a las 22:48 me escribiste: > > On 2009-04-18 22:25:32 +0200, Don said: > > > > >Leandro Lucarella wrote: > > >>Robert Jacques, el 18 de abril a las 11:56 me escribiste: > > >>>On Sat, 18 Apr 2009 11:24:14

Re: GC object finalization not guaranteed

2009-04-18 Thread Robert Jacques
On Sat, 18 Apr 2009 16:25:32 -0400, Don wrote: Leandro Lucarella wrote: Robert Jacques, el 18 de abril a las 11:56 me escribiste: On Sat, 18 Apr 2009 11:24:14 -0400, Leandro Lucarella wrote: I've just found out[1] this[2]: The garbage collector is not guaranteed to run the destruc

Re: GC object finalization not guaranteed

2009-04-18 Thread Leandro Lucarella
Fawzi Mohamed, el 18 de abril a las 22:48 me escribiste: > On 2009-04-18 22:25:32 +0200, Don said: > > >Leandro Lucarella wrote: > >>Robert Jacques, el 18 de abril a las 11:56 me escribiste: > >>>On Sat, 18 Apr 2009 11:24:14 -0400, Leandro Lucarella > >>>wrote: > I've just found out[1] this

Re: GC object finalization not guaranteed

2009-04-18 Thread Fawzi Mohamed
On 2009-04-18 22:25:32 +0200, Don said: Leandro Lucarella wrote: Robert Jacques, el 18 de abril a las 11:56 me escribiste: On Sat, 18 Apr 2009 11:24:14 -0400, Leandro Lucarella wrote: I've just found out[1] this[2]: The garbage collector is not guaranteed to run the destructor for

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Denis Koroskin
On Sat, 18 Apr 2009 21:43:15 +0400, Steven Schveighoffer wrote: On Fri, 17 Apr 2009 23:43:22 -0400, Steven Schveighoffer wrote: On Fri, 17 Apr 2009 21:54:52 -0400, Steven Schveighoffer wrote: Andrei wrote: We are discussing a language extension. That language extension will allow a

Re: GC object finalization not guaranteed

2009-04-18 Thread Leandro Lucarella
Don, el 18 de abril a las 22:25 me escribiste: > >The current GC implementation don't call finalizers for data that's still > >reference when the program *ended* (this is allowed by the specs, so it's > >fine, the question is why it's allowed by the specs). > > I don't understand why D even has fi

Re: GC object finalization not guaranteed

2009-04-18 Thread Don
Leandro Lucarella wrote: Robert Jacques, el 18 de abril a las 11:56 me escribiste: On Sat, 18 Apr 2009 11:24:14 -0400, Leandro Lucarella wrote: I've just found out[1] this[2]: The garbage collector is not guaranteed to run the destructor for all unreferenced objects. Is there

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Don
Michel Fortin wrote: On 2009-04-18 11:19:38 -0400, Andrei Alexandrescu said: I'm confused. Isn't it clear that at the moment we "have" the ability to pass a function name as a runtime string? Indeed, you can pass the template argument as a runtime argument to another function. No misunders

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread davidl
在 Sun, 19 Apr 2009 03:42:02 +0800,Michel Fortin 写道: On 2009-04-18 11:19:38 -0400, Andrei Alexandrescu said: I'm confused. Isn't it clear that at the moment we "have" the ability to pass a function name as a runtime string? Indeed, you can pass the template argument as a runtime argume

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread davidl
在 Sun, 19 Apr 2009 03:15:02 +0800,Daniel Keep 写道: Andrei Alexandrescu wrote: Michel Fortin wrote: ... Andrei, I think you, and perhaps everyone here, are overlooking one small but important detail. opDotExp, if a template like you're adovcating, undermines future runtime dynamic call ca

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Yigal Chripun
On 18/04/2009 21:16, Andrei Alexandrescu wrote: bearophile wrote: Andrei Alexandrescu: Yes. The amount of confusion in this thread is staggering. I think I have misunderstood about the whole thread then. If the string isn't determined at run time, then this thing isn't useful for my purposes,

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Adam Burton
Jason House wrote: > Andrei Alexandrescu Wrote: > >> Nick Sabalausky wrote: >> > Please do not accuse me of such a thing simply because I haven't >> > changed my opinion. You've held your ground as well, so I could just as >> > easily accuse you of being closed-minded and merely reaffirming a you

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Michel Fortin
On 2009-04-18 11:19:38 -0400, Andrei Alexandrescu said: I'm confused. Isn't it clear that at the moment we "have" the ability to pass a function name as a runtime string? Indeed, you can pass the template argument as a runtime argument to another function. No misunderstanding here. What

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread davidl
在 Sun, 19 Apr 2009 02:16:30 +0800,Andrei Alexandrescu 写道: bearophile wrote: Andrei Alexandrescu: Yes. The amount of confusion in this thread is staggering. I think I have misunderstood about the whole thread then. If the string isn't determined at run time, then this thing isn't useful f

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Daniel Keep
Andrei Alexandrescu wrote: > Michel Fortin wrote: >> ... >> >> Andrei, I think you, and perhaps everyone here, are overlooking one >> small but important detail. >> >> opDotExp, if a template like you're adovcating, undermines future >> runtime dynamic call capabilities (which are part of most ru

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Daniel Keep
bearophile wrote: > downs: >> bearophile: >>> But a static foreach (on a static data structure that has opApply) is not >>> doable yet, I think. >> Foreach on a tuple is evaluated at compile-time. > > Yes, that's the whole point of that Range!(). > But you can't use that trick on an associative

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Andrei Alexandrescu
Walter Bright wrote: Andrei Alexandrescu wrote: Daniel Keep wrote: There's an interesting idea... Instead of "No member 'foo'", you could have "No member 'foo'; did you mean 'far' or 'fur'?" Heh. The string kernels in std.numeric (http://erdani.dreamhosters.com/d/web/phobos/std_numeric.html

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Walter Bright
Andrei Alexandrescu wrote: Daniel Keep wrote: There's an interesting idea... Instead of "No member 'foo'", you could have "No member 'foo'; did you mean 'far' or 'fur'?" Heh. The string kernels in std.numeric (http://erdani.dreamhosters.com/d/web/phobos/std_numeric.html) are to help with ex

Re: Ternary Search Trees

2009-04-18 Thread bearophile
This is the final version I am added to the dlibs: / To create a memory pool of a native item, like structs. Not thread-safe. It allows to create new items (it performs block-allocations for speed), and then free them all at once (and then you can creat

Re: Templated Matrix class

2009-04-18 Thread bearophile
import std.stdio: writefln; import std.string: format; class Matrix(T) { private T[][] m; this() {} this(int r, int c) { this.m = new T[][](r, c); } this(int r, int c, T x) { this.m = new T[][](r, c); foreach (ref row; this.m) row[] = x;

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Andrei Alexandrescu
bearophile wrote: Andrei Alexandrescu: Yes. The amount of confusion in this thread is staggering. I think I have misunderstood about the whole thread then. If the string isn't determined at run time, then this thing isn't useful for my purposes, and it's not close to the object-C as I was ta

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread bearophile
Andrei Alexandrescu: > Yes. The amount of confusion in this thread is staggering. I think I have misunderstood about the whole thread then. If the string isn't determined at run time, then this thing isn't useful for my purposes, and it's not close to the object-C as I was talking about, and it'

Templated Matrix class

2009-04-18 Thread Andrew Spott
So, I'm trying to create a matrix class that is templated, but I don't really understand templates, so I don't know why this doesn't work. Any idea why I can't seem to do 2-D arrays? -Andrew module matrix; private import std.string; class Matrix(T) { private: T[][] ma;

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Andrei Alexandrescu
Steven Schveighoffer wrote: I gave this a lot of thought, and I think here is a possible solution: the main reason I'm hesitant on this idea is because of code like this: class X { auto opDotExp(string fname, T...)(T args) { if(fname == "blah") return foo(args); else if(fna

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Andrei Alexandrescu
Don wrote: I don't see _anything_ dynamic in this proposal, actually. Yes. The amount of confusion in this thread is staggering. I think the right question to ask is, "what does opDotExp bring, that wasn't there before?" Is it reflection of any kind? No. Is it the ability to encode operati

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Steven Schveighoffer
On Fri, 17 Apr 2009 23:43:22 -0400, Steven Schveighoffer wrote: On Fri, 17 Apr 2009 21:54:52 -0400, Steven Schveighoffer wrote: Andrei wrote: We are discussing a language extension. That language extension will allow a type to choose flexibility in defining methods dynamically, while

Re: GC object finalization not guaranteed

2009-04-18 Thread Leandro Lucarella
Robert Jacques, el 18 de abril a las 11:56 me escribiste: > On Sat, 18 Apr 2009 11:24:14 -0400, Leandro Lucarella > wrote: > >I've just found out[1] this[2]: > > > > The garbage collector is not guaranteed to run the destructor for > > all unreferenced objects. > > > >Is there any reason

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread BCS
Hello Denis, On Sat, 18 Apr 2009 19:46:36 +0400, BCS wrote: not exactly 1-to-1 but: Bad example: So I saw, I'm just saying it's not without precedent.

Re: GC object finalization not guaranteed

2009-04-18 Thread Robert Jacques
On Sat, 18 Apr 2009 11:24:14 -0400, Leandro Lucarella wrote: I've just found out[1] this[2]: The garbage collector is not guaranteed to run the destructor for all unreferenced objects. Is there any reason why D can't guarantee that all finalizers will be called, at least when

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread BCS
Hello Christopher, Testing the logic of your code will catch the latter error and not the former. But the former isn't an error, if it has the same result. IIRC dynamic language do gobs of TDD/unittests because they have no choice for just this reason. Any other approach and you have no clu

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Denis Koroskin
On Sat, 18 Apr 2009 19:46:36 +0400, BCS wrote: Hello Andrei, The dynamic behavior is indicated by the use of opDotExp. The redundancy of the two notations doesn't quite sit well. Andrei not exactly 1-to-1 but: abstract class C { void foo(); } // works class D { void foo(); } // fails: l

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread BCS
Hello Andrei, The dynamic behavior is indicated by the use of opDotExp. The redundancy of the two notations doesn't quite sit well. Andrei not exactly 1-to-1 but: abstract class C { void foo(); } // works class D { void foo(); } // fails: link error

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread BCS
Hello bearophile, Andrei Alexandrescu: I know, but at about the fiftienth one you get sick of it. In some situations static loops can be useful, but in general isn't the compiler supposed to be able to perform loop unrolling by itself, according to compilation arguments and according to how

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Don
bearophile wrote: SandeepK: I too am having difficulty in understanding the benefit of this particular proposal. Read the thread, some of the answers give several use cases. If I understand it right, the string essentially is still static and hence known at compile time?< It can be unkn

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Leandro Lucarella
Daniel Keep, el 18 de abril a las 19:08 me escribiste: > > So I have created this, that I actually use in a large Graph class of mine > > that has many methods: > > http://code.activestate.com/recipes/409000/ > > Such class can be used from the interactive shell too, to play with graphs > > in an

GC object finalization not guaranteed

2009-04-18 Thread Leandro Lucarella
I've just found out[1] this[2]: The garbage collector is not guaranteed to run the destructor for all unreferenced objects. Is there any reason why D can't guarantee that all finalizers will be called, at least when the program ends? [1] http://proj.llucax.com.ar/blog/dgc/blog/po

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread bearophile
Andrei Alexandrescu: > I know, but at about the fiftienth one you get sick of it. In some situations static loops can be useful, but in general isn't the compiler supposed to be able to perform loop unrolling by itself, according to compilation arguments and according to how much code is present

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Andrei Alexandrescu
Michel Fortin wrote: On 2009-04-18 03:23:21 -0400, Andrei Alexandrescu said: If you want to invoke a method known as a string variable, opDot or whatever has nothing to do with it. You don't need any change to the language at all, because you'd write: string foo = "bar"; d.call(foo); // ca

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Andrei Alexandrescu
downs wrote: Static loops are simple, at least in functions. import std.stdio; template Tuple(T...) { alias T Tuple; } template Repeat(T, int I) { static if (!I) alias Tuple!() Repeat; else alias Tuple!(T, Repeat!(T, I-1)) Repeat; } void main() { foreach (i, bogus; Repeat!(void, 15)) wr

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Andrei Alexandrescu
Daniel Keep wrote: bearophile wrote: Andrei Alexandrescu: Pascalize!S s; s.foo(); // works s.Foo(); // works too s.fOo(); // yup, works again I can show something even more extreme :-) What we are discussing in this thread is named the __getattr__ method in Python: http://docs.python.org/ref

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread bearophile
SandeepK: > I too am having difficulty in understanding the benefit of this particular > proposal. Read the thread, some of the answers give several use cases. >If I understand it right, the string essentially is still static and hence >known at compile time?< It can be unknown at compile-tim

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread SandeepK
Leandro Lucarella Wrote: > > So now, let's try this again: > > What is this usefulness you speak of that traditional dynamic methods > > and/or > > opDotSrc dynamic methods have that is more useful than a dispatch method? > > Uniform (and better) syntax. It's just about that. I too am having

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Leandro Lucarella
Nick Sabalausky, el 18 de abril a las 02:19 me escribiste: > "Leandro Lucarella" wrote in message > news:20090417231958.gb27...@homero.springfield.home... > > Nick Sabalausky, el 17 de abril a las 16:48 me escribiste: > >> "Leandro Lucarella" wrote in message > >> news:20090417191634.ga15...@ho

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Christopher Wright
Daniel Keep wrote: Cool! I suggest the rewrite: c.unknownmethod(args) -> c.opDotExp!("unknownmethod")(args) That way you have the option of handling the method name statically or dynamically. Careful. If you do that, you need to make sure it's possible to invoke a given method at runtime. A

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Christopher Wright
Nick Sabalausky wrote: "Christopher Wright" wrote in message news:gsb05g$2in...@digitalmars.com... Assuming that you are testing the logic of your application, you will trivially check things like accessing "legnth" rather than "length" -- under the assumption that these two methods would do d

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Christopher Wright
Don wrote: Steven Schveighoffer wrote: On Fri, 17 Apr 2009 21:54:52 -0400, Steven Schveighoffer wrote: Andrei wrote: We are discussing a language extension. That language extension will allow a type to choose flexibility in defining methods dynamically, while being otherwise integrated syn

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Christopher Wright
Steven Schveighoffer wrote: On Fri, 17 Apr 2009 21:54:52 -0400, Steven Schveighoffer wrote: Andrei wrote: We are discussing a language extension. That language extension will allow a type to choose flexibility in defining methods dynamically, while being otherwise integrated syntactically w

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread Michel Fortin
On 2009-04-18 03:23:21 -0400, Andrei Alexandrescu said: If you want to invoke a method known as a string variable, opDot or whatever has nothing to do with it. You don't need any change to the language at all, because you'd write: string foo = "bar"; d.call(foo); // call method bar What op

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread bearophile
downs: > bearophile: > > But a static foreach (on a static data structure that has opApply) is not > > doable yet, I think. > > Foreach on a tuple is evaluated at compile-time. Yes, that's the whole point of that Range!(). But you can't use that trick on an associative array, or a struct with OpA

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread downs
bearophile wrote: > downs: >> Static loops are simple, at least in functions. >> ... >> void main() { >> foreach (i, bogus; Repeat!(void, 15)) >> writefln(i); >> } > > My dlibs have: > Range!([start], stop[, step]) > with it I think your code becomes: > > void main() { > foreach (i; Ra

  1   2   >