digitalmars.D - I have a dream about external methods too ...
- Andrew Fedoniouk (26/26) Mar 13 2005 About external methods (or multimethods?)....
- pragma (8/33) Mar 13 2005 I couldn't agree more. In fact, I proposed almost the same exact thing ...
- Andrew Fedoniouk (9/48) Mar 13 2005 :)
- Ben Hinkle (15/19) Mar 14 2005 nice write-up! That's a great use of wiki. I like this external method s...
- pragma (12/21) Mar 14 2005 Thank you. I plan on doing this more often in the future, as per my sug...
- Ben Hinkle (1/3) Mar 14 2005 How do I get to the proposal(s) from the FrontPage of the wiki?
- pragma (7/10) Mar 14 2005 The closest thing we have is the Feature Request List, which is anything...
- Sean Kelly (5/11) Mar 14 2005 I missed this the first time around. It's an intruging idea, particular...
- Lionello Lunesu (20/20) Mar 14 2005 Well, I thought it could easily be done by just making a method that tak...
- Sean Kelly (4/10) Mar 14 2005 Sadly, this trick only works for arrays. I would love to see it enabled...
- Charles (7/21) Mar 14 2005 Aye me too. Would this eliminate the need for multi-methods ?
- Sean Kelly (5/9) Mar 14 2005 If you mean the proposed typedef block trick, then no. But consistency ...
- Craig Black (8/9) Mar 14 2005 No. Here you are essentially extending a class or type similar to C#'s
- Charles (5/15) Mar 14 2005 I would :). Been trying to find a good resource on the web, have a link...
- Joey Peters (10/36) Mar 14 2005 That somehow looks strange and unlikely, but useful. It could work a lit...
- Craig Black (2/3) Mar 14 2005 This is a great idea, but this is not "multimethods".
About external methods (or multimethods?).... I would like to be able to write something like this one day.... Would be extremely nice.... typedef wchar[] string { void insert(int at, wchar what) { int num = this.length; this.length = num + 1; ...... } void opCatAssign(wchar what) { this.length = this.length + 1; this[this.length - 1] = what; } .... } typedef uint color { uint red() { return this & 0xFF; } uint green() { ... } uint blue() { ... } } Huh? Andrew.
Mar 13 2005
In article <d136o4$mbg$1 digitaldaemon.com>, Andrew Fedoniouk says...About external methods (or multimethods?).... I would like to be able to write something like this one day.... Would be extremely nice.... typedef wchar[] string { void insert(int at, wchar what) { int num = this.length; this.length = num + 1; ...... } void opCatAssign(wchar what) { this.length = this.length + 1; this[this.length - 1] = what; } .... } typedef uint color { uint red() { return this & 0xFF; } uint green() { ... } uint blue() { ... } } Huh?I couldn't agree more. In fact, I proposed almost the same exact thing a (long) while back. (sorry if that was what you were referring to) ;) OP: http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/8159 Proposal: http://www.prowiki.org/wiki4d/wiki.cgi?Typedef-Block - EricAnderton at yahoo
Mar 13 2005
:) I have not seen your post, Eric! Honestly! If two wise men (yet decent :) independently (sic!) come up to the same idea then it means that this idea at least is worth something :) Andrew. "pragma" <pragma_member pathlink.com> wrote in message news:d1380p$o27$1 digitaldaemon.com...In article <d136o4$mbg$1 digitaldaemon.com>, Andrew Fedoniouk says...About external methods (or multimethods?).... I would like to be able to write something like this one day.... Would be extremely nice.... typedef wchar[] string { void insert(int at, wchar what) { int num = this.length; this.length = num + 1; ...... } void opCatAssign(wchar what) { this.length = this.length + 1; this[this.length - 1] = what; } .... } typedef uint color { uint red() { return this & 0xFF; } uint green() { ... } uint blue() { ... } } Huh?I couldn't agree more. In fact, I proposed almost the same exact thing a (long) while back. (sorry if that was what you were referring to) ;) OP: http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/8159 Proposal: http://www.prowiki.org/wiki4d/wiki.cgi?Typedef-Block - EricAnderton at yahoo
Mar 13 2005
OP: http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/8159 Proposal: http://www.prowiki.org/wiki4d/wiki.cgi?Typedef-Blocknice write-up! That's a great use of wiki. I like this external method stuff. It would make extending basic types easier. A variation on all this would be something that makes official the array-method hack: return-type fcnname(T[], ..) can be called like x.fcnname(...). The general form of this would be return-type fcnname(T, ...) can be called with x.fcnname(...). Maybe a concrete proposal for this has been suggested already, too? For example, The name lookup and overloading rules would have to be massaged so that fcnname(T,...) could be found. I'll ponder this some more and probably try to write up as nice a wiki proposal as you did for the typedef extension. -Ben
Mar 14 2005
In article <d14403$1lbo$1 digitaldaemon.com>, Ben Hinkle says...Thank you. I plan on doing this more often in the future, as per my suggestions for improving the DNG. Please, post any critiques you have to wiki if you feel like it. Its not captured on the page, but a major motivation I have for this is to provide a way to overload operators for scalars. Right now, that's and advantage that C++ has over D.OP: http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/8159 Proposal: http://www.prowiki.org/wiki4d/wiki.cgi?Typedef-Blocknice write-up! That's a great use of wiki.I like this external method stuff. It would make extending basic types easier. A variation on all this would be something that makes official the array-method hackThat gets my vote too, provided that operator overloads can be worked-in. I prefer the typedef-block solution only because it forces one to create a new type, so the built-in primitives can stay as-is. I think that's important, as I can easily see operator overloads on the built-in types as a font of bugs. - EricAnderton at yahoo
Mar 14 2005
Proposal: http://www.prowiki.org/wiki4d/wiki.cgi?Typedef-BlockHow do I get to the proposal(s) from the FrontPage of the wiki?
Mar 14 2005
In article <d14bbd$1tok$1 digitaldaemon.com>, Ben Hinkle says...The closest thing we have is the Feature Request List, which is anything but a stack of formal proposals. http://www.prowiki.org/wiki4d/wiki.cgi?FeatureRequestList .. and it's not linked directly from the front page, but is available via "Idea Discussion". - EricAnderton at yahooProposal: http://www.prowiki.org/wiki4d/wiki.cgi?Typedef-BlockHow do I get to the proposal(s) from the FrontPage of the wiki?
Mar 14 2005
In article <d1380p$o27$1 digitaldaemon.com>, pragma says...I couldn't agree more. In fact, I proposed almost the same exact thing a (long) while back. (sorry if that was what you were referring to) ;) OP: http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/8159 Proposal: http://www.prowiki.org/wiki4d/wiki.cgi?Typedef-BlockI missed this the first time around. It's an intruging idea, particularly in its ability to extend the functionality of primitive types. Assuming it wouldn't be terribly difficult to implement, I'm all for it. Sean
Mar 14 2005
Well, I thought it could easily be done by just making a method that takes a 'color' but then calling it like some_color.red() instead of red(some_color)... But it didn't work: The method 'toupper' can be called as string.toupper(), but why can't the same be done for 'color' ? Even without the typedef (using uint) it won't work? Lionello void toupper( char[] c ) { c ~= "bla"; } typedef uint color; int red( color c ) { return c&0xFF; } int main( char[][]arg ) { char[] string; string.toupper(); uint c; return c.red(); }
Mar 14 2005
In article <d13ggf$10rn$1 digitaldaemon.com>, Lionello Lunesu says...Well, I thought it could easily be done by just making a method that takes a 'color' but then calling it like some_color.red() instead of red(some_color)... But it didn't work: The method 'toupper' can be called as string.toupper(), but why can't the same be done for 'color' ? Even without the typedef (using uint) it won't work?Sadly, this trick only works for arrays. I would love to see it enabled for primitive types as well. Sean
Mar 14 2005
Sadly, this trick only works for arrays. I would love to see it enabledforprimitive types as well.Aye me too. Would this eliminate the need for multi-methods ? Charlie "Sean Kelly" <sean f4.ca> wrote in message news:d14u8u$2hks$1 digitaldaemon.com...In article <d13ggf$10rn$1 digitaldaemon.com>, Lionello Lunesu says...takes aWell, I thought it could easily be done by just making a method thatfor'color' but then calling it like some_color.red() instead of red(some_color)... But it didn't work: The method 'toupper' can be called as string.toupper(), but why can't the same be done for 'color' ? Even without the typedef (using uint) it won't work?Sadly, this trick only works for arrays. I would love to see it enabledprimitive types as well. Sean
Mar 14 2005
In article <d14vgd$2j03$1 digitaldaemon.com>, Charles says...If you mean the proposed typedef block trick, then no. But consistency is generally a good thing, and this could have an interesting impact on template code. SeanSadly, this trick only works for arrays. I would love to see it enabledforprimitive types as well.Aye me too. Would this eliminate the need for multi-methods ?
Mar 14 2005
Aye me too. Would this eliminate the need for multi-methods ?partial classes. This is not a multimethod, nor does it replace their functionality. Multimethods are an elegant way to perform multiple dispatch. They define relationships between objects. Where virtual methods use 1-dimensional vtables, multimethods are N-dimensional method tables, because multiple parameters in a multimethod can be "virtual". If you would like to know more about multimethods, just ask. -Craig
Mar 14 2005
If you would like to know more about multimethods, just ask.I would :). Been trying to find a good resource on the web, have a link ? Charlie "Craig Black" <cblack ara.com> wrote in message news:d151j0$2l37$1 digitaldaemon.com...methodsAye me too. Would this eliminate the need for multi-methods ?partial classes. This is not a multimethod, nor does it replace their functionality. Multimethods are an elegant way to perform multiple dispatch. They define relationships between objects. Where virtualuse 1-dimensional vtables, multimethods are N-dimensional method tables, because multiple parameters in a multimethod can be "virtual". If you would like to know more about multimethods, just ask. -Craig
Mar 14 2005
That somehow looks strange and unlikely, but useful. It could work a little different, much like how you can do: enum Something : int { ... } Perhaps one should be able to do: But it just doesn't make sense somehow. "Andrew Fedoniouk" <news terrainformatica.com> schreef in bericht news:d136o4$mbg$1 digitaldaemon.com...About external methods (or multimethods?).... I would like to be able to write something like this one day.... Would be extremely nice.... typedef wchar[] string { void insert(int at, wchar what) { int num = this.length; this.length = num + 1; ...... } void opCatAssign(wchar what) { this.length = this.length + 1; this[this.length - 1] = what; } .... } typedef uint color { uint red() { return this & 0xFF; } uint green() { ... } uint blue() { ... } } Huh? Andrew.
Mar 14 2005
About external methods (or multimethods?)....This is a great idea, but this is not "multimethods". -Craig
Mar 14 2005