Re: writeln, UFCS and flip

2013-04-26 Thread Tyro[17]
On 4/26/13 4:15 PM, bearophile wrote: Tyro[17]: While flip2 does: flip2!foo(a, b, c) === foo(b, a, c) flip2!foo(a, b, c, d) === foo(b, a, c, d) and this rotate Really? Just swapping the first two arguments and leaving the others at their place is for a rotate? Actually, by brain

Re: writeln, UFCS and flip

2013-04-26 Thread Tyro[17]
On 4/26/13 5:09 PM, Tyro[17] wrote: On 4/26/13 4:15 PM, bearophile wrote: Tyro[17]: While flip2 does: flip2!foo(a, b, c) === foo(b, a, c) flip2!foo(a, b, c, d) === foo(b, a, c, d) and this rotate Really? Just swapping the first two arguments and leaving the others at their place is

Re: writeln, UFCS and flip

2013-04-26 Thread bearophile
Tyro[17]: With that clarification, I just have one more question, since flip does what is intuitively implied by a reverse function OK, better to name it reversedArgs :-) and flip2 does what is intuitively implied by a flip function, flip2 swaps just the fist two arguments and leaves the

writeln, UFCS and flip

2013-04-25 Thread bearophile
writeln is able to write a whole range: import std.stdio, std.algorithm, std.range; void main() { 10.iota.map!(x = x ^^ 2).writeln; } Output: [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] - - - - - - - - - - - - - - - - But if you want to format the range in some way you have to change the

Re: writeln, UFCS and flip

2013-04-25 Thread bearophile
This is not a real use case because the reduce!() of Phobos will be fixed for UCFS, but sometimes you can't swap the arguments of a function: import std.stdio, std.algorithm, std.range; /// flip2!foo(a, b, c...) === foo(b, a, c...) template flip2(alias callable) { auto flip2(T2,

Re: writeln, UFCS and flip

2013-04-25 Thread ixid
Doesn't binaryReverseArgs in std.functional already do this? Flip is a much, much better name though.

Re: writeln, UFCS and flip

2013-04-25 Thread ixid
the output of a function. It's useful for normal code as well as UFCS. string temp = myFun(); temp.writeln; result ~= temp ~ \n;

Re: writeln, UFCS and flip

2013-04-25 Thread bearophile
On Thursday, 25 April 2013 at 16:20:39 UTC, ixid wrote: Doesn't binaryReverseArgs in std.functional already do this? Right, it's the flip I have suggested here. My flip2 is a little different. I will think about this. Though I still think write functions passing on the data would be

Re: writeln, UFCS and flip

2013-04-25 Thread Timon Gehr
On 04/25/2013 05:09 PM, bearophile wrote: ... What do you think? ... I think what you call flip2 should be called flip.

Re: Playing with ranges and ufcs

2013-02-28 Thread Andrea Fontana
On Wednesday, 27 February 2013 at 23:43:49 UTC, bearophile wrote: void main() { auto a = [0,1,2,3,4,5,6,7,8,9][5 .. 2]; } I tried it too, hoping for something like [5,4,3] or at least [4,3,2] (== [0,1,2,3,4,5,6,7,8,9][2..5].reverse)

Playing with ranges and ufcs

2013-02-27 Thread Andrea Fontana
This command: writeln(iota(10).cycle()[5..2].take(4)); print: [5, 6, 7, 8] Shouldn't [5..2] slice throw a compile/runtime error?

Re: Playing with ranges and ufcs

2013-02-27 Thread bearophile
Andrea Fontana: writeln(iota(10).cycle()[5..2].take(4)); print: [5, 6, 7, 8] Shouldn't [5..2] slice throw a compile/runtime error? Please file it in bugzilla. The opSlice of cycle() lacks those pre-conditions or tests, and there are not enough unittests in Phobos to catch this simple

Re: Playing with ranges and ufcs

2013-02-27 Thread Jonathan M Davis
On Wednesday, February 27, 2013 23:48:05 bearophile wrote: Andrea Fontana: writeln(iota(10).cycle()[5..2].take(4)); print: [5, 6, 7, 8] Shouldn't [5..2] slice throw a compile/runtime error? Please file it in bugzilla. The opSlice of cycle() lacks those pre-conditions or

Re: Playing with ranges and ufcs

2013-02-27 Thread Andrea Fontana
On Wednesday, 27 February 2013 at 22:48:06 UTC, bearophile wrote: Andrea Fontana: writeln(iota(10).cycle()[5..2].take(4)); print: [5, 6, 7, 8] Shouldn't [5..2] slice throw a compile/runtime error? Please file it in bugzilla. The opSlice of cycle() lacks those pre-conditions or tests,

Re: Playing with ranges and ufcs

2013-02-27 Thread bearophile
Andrea Fontana: Done! I was about to file it myself, so I have added a bit more meat to your bug report. Bye, bearophile

Re: Playing with ranges and ufcs

2013-02-27 Thread bearophile
Jonathan M Davis: What it should be doing is using version(assert) to throw a RangeError if the arguments are invalid, but the addition of version(assert) is quite recent (previously, the best that could have been done was to assert). Do you mean something like this? auto opSlice(size_t i,

Re: Playing with ranges and ufcs

2013-02-27 Thread bearophile
auto opSlice(size_t i, size_t j) in { assert(i = j, some message here); } body { auto retval = this.save; retval._index += i; return takeExactly(retval, j - i); } This is the bug opened by Andrea Fontana for this thread: http://d.puremagic.com/issues/show_bug.cgi?id=9612 At

Re: Playing with ranges and ufcs

2013-02-27 Thread bearophile
To do the same with user-defined structures time ago I have suggested this, that is currently closed waiting for a better solution: What I meant to say is that if the assert(i = j) is inside the pre-condition then there's a hope to run it at compile time introducing some new trick inside the

Re: Playing with ranges and ufcs

2013-02-27 Thread Jonathan M Davis
On Thursday, February 28, 2013 00:46:56 bearophile wrote: To do the same with user-defined structures time ago I have suggested this, that is currently closed waiting for a better solution: What I meant to say is that if the assert(i = j) is inside the pre-condition then there's a hope

Re: Playing with ranges and ufcs

2013-02-27 Thread Jonathan M Davis
On Thursday, February 28, 2013 00:35:08 bearophile wrote: Jonathan M Davis: What it should be doing is using version(assert) to throw a RangeError if the arguments are invalid, but the addition of version(assert) is quite recent (previously, the best that could have been done was to

Re: Playing with ranges and ufcs

2013-02-27 Thread bearophile
Jonathan M Davis: Because then it more closely matches how arrays work. The only part that doesn't is that it's fully tied to -release rather than -noboundschecked. I see, thank you. Honestly, I think that that's a complete pipe dream anyway, I will keep dreaming for some more decades.

UFCS opDispatch

2013-01-16 Thread Nick Sabalausky
Unfortunately, opDispatch [silently] takes precedence over UFCS. I don't suppose there's any way to make a UFCS function call override opDispatch without either ditching UFCS or altering/removing the opDispatch itself?

Re: UFCS opDispatch

2013-01-16 Thread Simen Kjaeraas
On 2013-01-16, 22:02, Nick Sabalausky wrote: Unfortunately, opDispatch [silently] takes precedence over UFCS. I don't suppose there's any way to make a UFCS function call override opDispatch without either ditching UFCS or altering/removing the opDispatch itself? Only solution I know

Re: Problem with UFCS

2012-10-18 Thread Michael
Thank you guys. I can't believe that haven't thought of that. I still feel that this is rather odd though. I would expect to be able to use UFCS in the scope that imports those libraries. Though I can definitely see how that might lead to obscure bugs. On Tuesday, 16 October 2012 at 17:07:36

Re: Operator overloading through UFCS doesn't work

2012-10-17 Thread Timon Gehr
that is not what UFCS does. but as soon as you import some other modules, authors of which also consider UFCS operators a good idea, Who has stated that? It just does not make sense to explicitly ban them, as they are not special. everything breaks including namespace conflict The usual disambiguation

Re: Operator overloading through UFCS doesn't work

2012-10-17 Thread Timon Gehr
On 10/14/2012 09:14 AM, Maxim Fomin wrote: On Sunday, 14 October 2012 at 07:01:30 UTC, Tommi wrote: Actually, it seems that alias this has precedence over UFCS. So, a free function opUnary wouldn't ever suit better than an actual method opUnary of the thing referred to by that alias

Re: Operator overloading through UFCS doesn't work

2012-10-17 Thread Maxim Fomin
On Wednesday, 17 October 2012 at 10:24:57 UTC, Artur Skawina wrote: Operator overloading can be abused - that's an obvious and well known fact. But that same feature can also be very useful, if used right. Worrying about UFCS problems in the context of op-overloading needlessly complicates

Re: Operator overloading through UFCS doesn't work

2012-10-17 Thread Timon Gehr
methods are special functions and not treating them as candidates for UFCS does make more sense. I do not understand how an operation that happens to be called '+' is fundamentally different from an operation that is called 'add'. The first one is an operator, which sometimes, may be rewritten

Re: Operator overloading through UFCS doesn't work

2012-10-17 Thread Maxim Fomin
to ... and then add methods Which is still not correct, because that is not what UFCS does. It is not correct as long as you cavil at lexis, however the statement has room for correction. but as soon as you import some other modules, authors of which also consider UFCS operators a good idea, Who

Re: Operator overloading through UFCS doesn't work

2012-10-17 Thread Artur Skawina
On 10/17/12 12:46, Timon Gehr wrote: On 10/15/2012 01:00 PM, Artur Skawina wrote: ... An overloaded operator is just another normal method; you get the same type of problems when dealing with normal methods - eg in types having an alias this - an UFCS method must take precedence over

Re: Operator overloading through UFCS doesn't work

2012-10-16 Thread Maxim Fomin
On Tuesday, 16 October 2012 at 00:50:54 UTC, Artur Skawina wrote: Actually, I'm not really in any camp. UFCS has several obvious problems plus likely quite a few more subtle ones. Ignoring the issues does not make them go away and the some-compiler-happens-to-implement-it-like-that-today

Re: Operator overloading through UFCS doesn't work

2012-10-16 Thread Tommi
On Monday, 15 October 2012 at 09:33:23 UTC, Maxim Fomin wrote: ---foo.d--- struct A { int i; alias i this; } ---bar.d--- int opUnary(string T)(A a) { ... } ... { ++a; } --- I. i is incremented, opUnary is not called. However opUnary matches better to the actual type and if it

Re: Problem with UFCS

2012-10-16 Thread Adam D. Ruppe
On Tuesday, 16 October 2012 at 16:12:06 UTC, Michael wrote: void main() { import std.range, std.stdio; The problem is that UFCS only works on functions in the global scope. The import inside a function makes them local, so it doesn't consider them in it. This is apparently

Re: Operator overloading through UFCS doesn't work

2012-10-16 Thread Maxim Fomin
happens if there are two conflict entities and one of them has higher priority than another. In case of UFCS depending on design two types of hijacks may happen: - either newly created free UFCS function hijacks existing method - or newly created method hijacks existing free function. Currently D

Re: Problem with UFCS

2012-10-16 Thread Jonathan M Davis
On Tuesday, October 16, 2012 18:28:14 Adam D. Ruppe wrote: On Tuesday, 16 October 2012 at 16:12:06 UTC, Michael wrote: void main() { import std.range, std.stdio; The problem is that UFCS only works on functions in the global scope. The import inside a function makes them local, so

Re: Operator overloading through UFCS doesn't work

2012-10-15 Thread Maxim Fomin
On Sunday, 14 October 2012 at 19:50:54 UTC, Artur Skawina wrote: On 10/14/12 08:13, Maxim Fomin wrote: The only mentioned reason is to allow writing operator overloading methods outside type scope - just because somebody (currently two people) consider it logical to broaden UFCS usage. It's

Re: Operator overloading through UFCS doesn't work

2012-10-15 Thread Maxim Fomin
cannot and must not ever hijack, i.e. modify existing functionality of a type. Free functions should only be able to add new functionality to a type. This is what currently happens with alias this vs free function which is accessed through UFCS: snip This shows current behavior. The issue

Re: Operator overloading through UFCS doesn't work

2012-10-15 Thread Artur Skawina
it logical to broaden UFCS usage. It's more than two people... Also, it's not about broadening UFCS usage, it's about making UFCS work properly. When UFCS was added to the language its purpose was to call free functions pretending you are invoking methods. It does it job pretty well

Re: Operator overloading through UFCS doesn't work

2012-10-15 Thread Maxim Fomin
On Monday, 15 October 2012 at 11:01:13 UTC, Artur Skawina wrote: UFCS has pros and cons. I could agree that it has problems and should be removed from the language completely. But if the feature is there, it should work, w/o any unnecessary special cases. Special cases would be created

Re: Operator overloading through UFCS doesn't work

2012-10-15 Thread Artur Skawina
On 10/15/12 17:49, Maxim Fomin wrote: On Monday, 15 October 2012 at 11:01:13 UTC, Artur Skawina wrote: UFCS has pros and cons. I could agree that it has problems and should be removed from the language completely. But if the feature is there, it should work, w/o any unnecessary special

Re: Operator overloading through UFCS doesn't work

2012-10-14 Thread Maxim Fomin
outside type scope - just because somebody (currently two people) consider it logical to broaden UFCS usage. This doesn't solve ay practical issue.

Re: Operator overloading through UFCS doesn't work

2012-10-14 Thread Maxim Fomin
On Saturday, 13 October 2012 at 17:01:27 UTC, Tommi wrote: Another way to describe my reasoning... According to TDPL, if var is a variable of a user-defined type, then: ++var gets rewritten as: var.opUnary!++() Not always. If user-defined type has an alias this to integer member, than

Re: Operator overloading through UFCS doesn't work

2012-10-14 Thread Tommi
than alias this, dmd will issue call to that function, it it see its declaration. Actually, it seems that alias this has precedence over UFCS. So, a free function opUnary wouldn't ever suit better than an actual method opUnary of the thing referred to by that alias this.

Re: Operator overloading through UFCS doesn't work

2012-10-14 Thread Maxim Fomin
and not treating them as candidates for UFCS does make more sense. I do not understand how an operation that happens to be called '+' is fundamentally different from an operation that is called 'add'. The first one is an operator, which sometimes, may be rewritten to function call, the second one

Re: Operator overloading through UFCS doesn't work

2012-10-14 Thread Maxim Fomin
On Sunday, 14 October 2012 at 07:01:30 UTC, Tommi wrote: Actually, it seems that alias this has precedence over UFCS. So, a free function opUnary wouldn't ever suit better than an actual method opUnary of the thing referred to by that alias this. http://dpaste.dzfl.pl/d0a4431d Free function

Re: Operator overloading through UFCS doesn't work

2012-10-14 Thread Artur Skawina
On 10/14/12 08:13, Maxim Fomin wrote: The only mentioned reason is to allow writing operator overloading methods outside type scope - just because somebody (currently two people) consider it logical to broaden UFCS usage. It's more than two people... Also, it's not about broadening UFCS

Re: Operator overloading through UFCS doesn't work

2012-10-14 Thread Tommi
functionality of a type. Free functions should only be able to add new functionality to a type. This is what currently happens with alias this vs free function which is accessed through UFCS: struct B { void fun() { writeln(B.fun()); } } struct A { B b; alias b

Operator overloading through UFCS doesn't work

2012-10-13 Thread Tommi
' I'd expect the lines tagged #3 and #4 to be rewritten by the compiler like so: ms.opUnary!++(); MyStruct ms3 = ms.opBinary!+(1); So, the inability to do operator overloading though UFCS must be a compiler bug, right?

Re: Operator overloading through UFCS doesn't work

2012-10-13 Thread Jakob Ovrum
On Saturday, 13 October 2012 at 08:36:19 UTC, Tommi wrote: Quote from TDPL: D’s approach to operator overloading is simple: whenever at least one participant in an operator expression is of user-defined type, the compiler rewrites the expression into a regular method call with a specific name.

Re: Operator overloading through UFCS doesn't work

2012-10-13 Thread Jonathan M Davis
On Saturday, October 13, 2012 11:06:27 Jakob Ovrum wrote: On Saturday, 13 October 2012 at 08:36:19 UTC, Tommi wrote: Quote from TDPL: D’s approach to operator overloading is simple: whenever at least one participant in an operator expression is of user-defined type, the compiler rewrites

Re: Operator overloading through UFCS doesn't work

2012-10-13 Thread Tommi
On Saturday, 13 October 2012 at 09:06:28 UTC, Jakob Ovrum wrote: Do note that this says *method* call. Your example doesn't use methods. Hence, the current state of operator overloading is consistent with TDPL. I don't agree with the last sentence. According to TDPL: 1) whenever at least one

Re: Operator overloading through UFCS doesn't work

2012-10-13 Thread Jonathan M Davis
that as: .opUnary!++(var); Just because the overloaded operator is rewritten into a method call underneath the hood doesn't mean that the UFCS rewrite also applies. The transformation of an operator to a method or a UFCS call to a free function is done _once_. You don't get both. It is most definitely _by

Re: Operator overloading through UFCS doesn't work

2012-10-13 Thread Tommi
On Saturday, 13 October 2012 at 09:50:05 UTC, Jonathan M Davis wrote: It is most definitely _by design_ that you cannot overload operators except as member functions. I don't understand this design choice then. I don't see any problem in allowing UFCS operators. Because of the way UFCS works

Re: Operator overloading through UFCS doesn't work

2012-10-13 Thread Maxim Fomin
problem in allowing UFCS operators. Because of the way UFCS works, it's guaranteed that there can't be any operator hijacking. I think implementing UFCS operator overloading is problematic. Firstly, you want to put this language addition too far. Secondly, compiler needs to know whether operator

Re: Operator overloading through UFCS doesn't work

2012-10-13 Thread Tommi
On Saturday, 13 October 2012 at 11:50:40 UTC, Maxim Fomin wrote: I think implementing UFCS operator overloading is problematic. Firstly, you want to put this language addition too far. I don't see this as taking UFCS functionality further. Rather, I think it's simply more logical

Re: Operator overloading through UFCS doesn't work

2012-10-13 Thread Maxim Fomin
On Saturday, 13 October 2012 at 15:06:14 UTC, Tommi wrote: On Saturday, 13 October 2012 at 11:50:40 UTC, Maxim Fomin wrote: I think implementing UFCS operator overloading is problematic. Firstly, you want to put this language addition too far. I don't see this as taking UFCS functionality

Re: Operator overloading through UFCS doesn't work

2012-10-13 Thread Tommi
On Saturday, 13 October 2012 at 16:02:25 UTC, Maxim Fomin wrote: From my point of view operator overloading methods are special functions and not treating them as candidates for UFCS does make more sense. I can think of only one thing that makes custom operator methods special or different

Re: Operator overloading through UFCS doesn't work

2012-10-13 Thread Tommi
Another way to describe my reasoning... According to TDPL, if var is a variable of a user-defined type, then: ++var gets rewritten as: var.opUnary!++() Thus, it would be very logical to assume that it doesn't matter whether you write: ++var ...or, write the following instead:

Re: Operator overloading through UFCS doesn't work

2012-10-13 Thread Timon Gehr
On 10/13/2012 06:02 PM, Maxim Fomin wrote: ... Different groups of people have different mind and same things produce different sense on them. From my point of view operator overloading methods are special functions and not treating them as candidates for UFCS does make more sense. I do

Re: Operator overloading through UFCS doesn't work

2012-10-13 Thread Jonathan M Davis
will be translated into another where it will then be assumed that the new language construct is using syntactic sugar such as UFCS, because _all_ of that syntactic sugar must be lowered to code which _isn't_ syntactic sugar anymore. It would be far more expensive to have to continually make passes

Re: Operator overloading through UFCS doesn't work

2012-10-13 Thread Timon Gehr
On 10/13/2012 10:15 PM, Jonathan M Davis wrote: ... construct is using syntactic sugar such as UFCS, because _all_ of that syntactic sugar must be lowered to code which _isn't_ syntactic sugar anymore. That is not what lowering means. It would be far more expensive to have to continually

Re: Operator overloading through UFCS doesn't work

2012-10-13 Thread H. S. Teoh
On Sun, Oct 14, 2012 at 12:12:01AM +0200, Timon Gehr wrote: On 10/13/2012 10:15 PM, Jonathan M Davis wrote: [...] but they _aren't_ mixed and they will _never_ be mixed. If it had _ever_ been intended that it be possible to overload operators as free functions, then we'd simply have made it so

Re: Operator overloading through UFCS doesn't work

2012-10-13 Thread Timon Gehr
? Or was it just a matter of not being implemented because nobody thought about it at the time? T Afaik free-function operator overloads (but not in the context of UFCS) were considered and turned down because D did not want to get amidst discussions about adding Koenig lookup. UFCS does not do Koenig

Writing UFCS function for any instance of a templated struct

2012-09-13 Thread Rene Zwanenburg
Hi, I'd like to write a function for a vector template which basically looks like struct Vec(T, size_t size) { T[size] e; } This template has a few properties with very common names like x, y, z, etc. To avoid mistakes I'd like to write a template constraint for UFCS functions so

Re: Writing UFCS function for any instance of a templated struct

2012-09-13 Thread David
a template constraint for UFCS functions so it accepts any instance of the Vec template, but nothing else. Something in the gist of auto innerProduct(T)(const T v1, const T v2) if(is(T == Vec)) { } How can I do this? I am doing it in gl3n like this: https://github.com/Dav1dde/gl3n/blob/master/gl3n

Re: Writing UFCS function for any instance of a templated struct

2012-09-13 Thread Rene Zwanenburg
properties with very common names like x, y, z, etc. To avoid mistakes I'd like to write a template constraint for UFCS functions so it accepts any instance of the Vec template, but nothing else. Something in the gist of auto innerProduct(T)(const T v1, const T v2) if(is(T == Vec)) { } How

Re: Writing UFCS function for any instance of a templated struct

2012-09-13 Thread bearophile
Rene Zwanenburg: How can I do this? One possible solution: struct Vec(T, size_t size) { T[size] e; } void innerProduct(T, size_t n)(const Vec!(T, n) v1, const Vec!(T, n) v2) {} void main() { Vec!(int, 3) v1, v2; innerProduct(v1, v2); } (While

Re: Writing UFCS function for any instance of a templated struct

2012-09-13 Thread Rene Zwanenburg
That's actually quite straightforward. I forgot how well D's type deduction works. Thanks On Thursday, 13 September 2012 at 11:01:18 UTC, bearophile wrote: Rene Zwanenburg: How can I do this? One possible solution: struct Vec(T, size_t size) { T[size] e; } void innerProduct(T,

Re: ufcs and integer params

2012-07-21 Thread Philippe Sigaud
Sorry, that should have been »kilo!gram«. It actually creates a new unit with tbua conversion factor of 1000 relative to the base unit (well, it does a few more things to handle cases like kilo!(milli!meter)), with the point being that the quantities are actually stored in memory verbatim,

Re: ufcs and integer params

2012-07-20 Thread Philippe Sigaud
clean it and push), but thought about offering prefix functions by themselves. Hmm, looking at it, I guess kilo is just 1000 as an enum in your code? That's a good idea. Anyway, multiplication is good, I just looked for an excuse to play with UFCS :) See http://klickverbot.at/code/units

Re: ufcs and integer params

2012-07-20 Thread David Nadlinger
On Friday, 20 July 2012 at 12:28:52 UTC, Philippe Sigaud wrote: Hmm, looking at it, I guess kilo is just 1000 as an enum in your code? That's a good idea. Sorry, that should have been »kilo!gram«. It actually creates a new unit with a conversion factor of 1000 relative to the base unit

Re: ufcs and integer params

2012-07-18 Thread Marco Leise
Am Sun, 15 Jul 2012 19:17:11 +0200 schrieb Philippe Sigaud philippe.sig...@gmail.com: On Sunday, July 15, 2012 05:30:55 Jay Norwood wrote: I see from this other discussions that it looks like 2.059 ( or maybe 2.060) does support something like 3.cm(). Not sure from the discussion if

Re: ufcs and integer params

2012-07-18 Thread David Nadlinger
On Monday, 16 July 2012 at 23:18:10 UTC, Adam D. Ruppe wrote: I'm another who is /vehemently/ against the utter idiocy that is the -property switch. Arguments! Yay!

Re: ufcs and integer params

2012-07-18 Thread David Nadlinger
On Wednesday, 18 July 2012 at 07:30:10 UTC, Marco Leise wrote: Am Sun, 15 Jul 2012 19:17:11 +0200 schrieb Philippe Sigaud philippe.sig...@gmail.com: […] auto distance = 100.km; auto speed = 120.km/hour; auto timeToDestination = distance/speed; // timeToDest is a time (seconds) The version

Re: ufcs and integer params

2012-07-18 Thread Adam D. Ruppe
On Wednesday, 18 July 2012 at 11:37:43 UTC, David Nadlinger wrote: Arguments! Yay! I've gone over this a dozen times on the group and on bugzilla, and I'm kinda sick of repeating it. -property breaks craploads of code. That's a huge negative, and nobody has even come close to countering that.

Re: ufcs and integer params

2012-07-18 Thread David Nadlinger
On Wednesday, 18 July 2012 at 12:30:46 UTC, Adam D. Ruppe wrote: 2) -property doesn't even get that right anyway. Not kidding, try it. -property might as well be renamed -break-my-code-and- give-me-ABSOLUTELY-NOTHING-in-return. Why, why would we ever consent to having that standard? I

Re: ufcs and integer params

2012-07-18 Thread Brad Roberts
On 7/18/2012 5:30 AM, Adam D. Ruppe wrote: On Wednesday, 18 July 2012 at 11:37:43 UTC, David Nadlinger wrote: Arguments! Yay! I've gone over this a dozen times on the group and on bugzilla, and I'm kinda sick of repeating it. -property breaks craploads of code. That's a huge negative,

Re: ufcs and integer params

2012-07-18 Thread Adam D. Ruppe
is it a real property without falsely marking stuff for UFCS chaining or whatever. It'd save me a lot of headaches on my range.empty's too. If we switch to this compromise position, I'm about 98% sure I'd vote yes (would have to actually try it to be certain).

Re: ufcs and integer params

2012-07-16 Thread Jacob Carlborg
On 2012-07-15 21:41, Jonathan M Davis wrote: And on a purely objective note, if you don't have property enforcement, you can't turn a property function into a variable, because even though it's supposed to be used as one, you can't guarantee that everyone's using it that way, and if they're

Re: ufcs and integer params

2012-07-16 Thread Jacob Carlborg
On 2012-07-15 23:56, Jonathan M Davis wrote: It's a matter of enforcing the correct syntax, which the compiler does all the time. It's just that you don't think that the compiler should care in this particular case, since it hasn't cared in the past. No, it's a matter of _what_ the correct

Re: ufcs and integer params

2012-07-16 Thread Jacob Carlborg
are applied is UFCS: array(map!(x=2*x)(range)); // should be fine range.map!(x=2*x).array; // so should this range.map!(x=2*x)().array(); // who needs this? Exactly. -- /Jacob Carlborg

Re: ufcs and integer params

2012-07-16 Thread Chris NS
compiler release that gave us pseudo-members -- the precursors to UFCS. The community discovered that these things were accepted by the compiler -- which was actually against the language spec at the time -- and further that the resulting code did the intuitively correct thing. Response

Re: ufcs and integer params

2012-07-16 Thread Timon Gehr
at properties. Afaik this first attempt was implemented roughly as designed. It is my understanding that @property was added later in order to fix the introduced ambiguities. It was the same accident loaded compiler release that gave us pseudo-members -- the precursors to UFCS. I still wonder how

Re: ufcs and integer params

2012-07-16 Thread Adam D. Ruppe
I'm another who is /vehemently/ against the utter idiocy that is the -property switch. I wonder: if we had another poll, a recall election if you will, how many people who said yes the first time would change their minds now? I betcha it'd be quite a few.

Re: ufcs and integer params

2012-07-16 Thread Chris NS
. The goal was simply class/struct/union member functions that could be swapped out for exposed fields, or vice versa, without any change in user code. It was the same accident loaded compiler release that gave us pseudo-members -- the precursors to UFCS. I still wonder how that could possibly

Re: ufcs and integer params

2012-07-15 Thread Philippe Sigaud
On Sunday, July 15, 2012 05:30:55 Jay Norwood wrote: I see from this other discussions that it looks like 2.059 ( or maybe 2.060) does support something like 3.cm(). Not sure from the discussion if it would also accept 3.cm as in the xtext/xtend example. Hi Jay, I had a little fun

Re: ufcs and integer params

2012-07-15 Thread Timon Gehr
example. http://forum.dlang.org/thread/smoniukqfxerutqrj...@forum.dlang.org UFCS (universal function call syntax) was added in 2.059. If cm is a function, then 3.cm() will work. If it's a property function, then 3.cm will work. If you don't compile with -property, then 3.cm will still work

Re: ufcs and integer params

2012-07-15 Thread Jonathan M Davis
the discussion if it would also accept 3.cm as in the xtext/xtend example. http://forum.dlang.org/thread/smoniukqfxerutqrj...@forum.dlang.org UFCS (universal function call syntax) was added in 2.059. If cm is a function, then 3.cm() will work. If it's a property function, then 3.cm

Re: ufcs and integer params

2012-07-15 Thread Jonathan M Davis
On Sunday, July 15, 2012 11:56:57 Jonathan M Davis wrote: What is enforced here? Why would it matter if anything is 'enforced'? If you marked it as a property, then it's supposed to be abstracting a variable and should be treated as one, just like if it's a normal function, it should be

Re: ufcs and integer params

2012-07-15 Thread Timon Gehr
On 07/15/2012 09:41 PM, Jonathan M Davis wrote: On Sunday, July 15, 2012 11:56:57 Jonathan M Davis wrote: What is enforced here? Why would it matter if anything is 'enforced'? If you marked it as a property, then it's supposed to be abstracting a variable and should be treated as one, just

Re: ufcs and integer params

2012-07-15 Thread Timon Gehr
something like 3.cm(). Not sure from the discussion if it would also accept 3.cm as in the xtext/xtend example. http://forum.dlang.org/thread/smoniukqfxerutqrj...@forum.dlang.org UFCS (universal function call syntax) was added in 2.059. If cm is a function, then 3.cm() will work. If it's

Re: ufcs and integer params

2012-07-15 Thread Jonathan M Davis
On Sunday, July 15, 2012 23:29:04 Timon Gehr wrote: The current plan is (and has been for some time) that -property will become the normal behavior, It is obvious that -property is broken and will not become the normal behaviour. It is obvious that -property needs to be fixed before it

Re: ufcs and integer params

2012-07-15 Thread Timon Gehr
On 07/15/2012 11:11 PM, Jonathan M Davis wrote: There are two levels to enforcement. Neither exist without -property. The absolutely minimal level is that anything marked with @property must be used as a property. Without this, you can't swap out a property function for a variable without

Re: ufcs and integer params

2012-07-15 Thread Jonathan M Davis
On Sunday, July 15, 2012 23:35:12 Timon Gehr wrote: The second level - i.e. strict property enforcement - also requires that non- property functions be called as functions. Exactly. This part is useless. And there, we will forever disagree. - Jonathan M Davis

Re: ufcs and integer params

2012-07-15 Thread Timon Gehr
On 07/15/2012 11:43 PM, Jonathan M Davis wrote: On Sunday, July 15, 2012 23:35:12 Timon Gehr wrote: The second level - i.e. strict property enforcement - also requires that non- property functions be called as functions. Exactly. This part is useless. And there, we will forever disagree.

Re: ufcs and integer params

2012-07-15 Thread Timon Gehr
On 07/15/2012 11:35 PM, Jonathan M Davis wrote: On Sunday, July 15, 2012 23:29:04 Timon Gehr wrote: The current plan is (and has been for some time) that -property will become the normal behavior, It is obvious that -property is broken and will not become the normal behaviour. It is obvious

Re: ufcs and integer params

2012-07-15 Thread Jonathan M Davis
On Sunday, July 15, 2012 23:47:58 Timon Gehr wrote: On 07/15/2012 11:43 PM, Jonathan M Davis wrote: On Sunday, July 15, 2012 23:35:12 Timon Gehr wrote: The second level - i.e. strict property enforcement - also requires that non- property functions be called as functions. Exactly. This

Re: ufcs and integer params

2012-07-15 Thread Timon Gehr
. This is a designed language feature, although it's a trivial one. eg. Eiffel and Scala have the same thing. The prime reason why I think it is beneficial if no more restrictions than necessary are applied is UFCS: array(map!(x=2*x)(range)); // should be fine range.map!(x=2*x).array; // so

ufcs and integer params

2012-07-14 Thread Jay Norwood
I was looking at the xtend example 4 Distances here, and see that their new generation capability includes ability to do 3.cm 10.mm , and these result in calls to cm(3) and mm(10). http://blog.efftinge.de/ I see that similar capability was discussed for D previously at the link below.

Re: ufcs and integer params

2012-07-14 Thread Jay Norwood
I see from this other discussions that it looks like 2.059 ( or maybe 2.060) does support something like 3.cm(). Not sure from the discussion if it would also accept 3.cm as in the xtext/xtend example. http://forum.dlang.org/thread/smoniukqfxerutqrj...@forum.dlang.org

<    1   2   3   4   5   >