The Case Against Annotations

2018-06-19 Thread Andrei Alexandrescu via Digitalmars-d
An interesting article. Most of the listed disadvantages of annotations are obviated by D's approach. https://blog.softwaremill.com/the-case-against-annotations-4b2fb170ed67

Re: Java type annotations, multi-precision

2014-02-09 Thread bearophile
Walter Bright: Much like how ROR and ROL is efficiently handled in compilers by having the compiler recognize the equivalent expression, I think the best way to handle these issues is by having the compiler recognize the multi-precision expressions, and rewrite it internally into the optimal

Re: Java type annotations, multi-precision

2014-02-09 Thread Walter Bright
On 2/9/2014 7:38 AM, bearophile wrote: This shows how a C-like language lacks some essential parts to use well the CPUs (both x86 and to ARM) to implement range integrals or multi-word integrals efficiently without using asm: http://accu.org/index.php/journals/1849 Much like how ROR and ROL is

Re: Java type annotations, multi-precision

2014-02-09 Thread Timon Gehr
On 02/09/2014 07:25 PM, Meta wrote: On Sunday, 9 February 2014 at 17:55:50 UTC, bearophile wrote: Francesco Cattoglio: Wow, they are totally coping! :P What's interesting is not just that Java has type annotations, but the details of this feature. That article show many details.

Re: Java type annotations, multi-precision

2014-02-09 Thread Meta
On Sunday, 9 February 2014 at 17:55:50 UTC, bearophile wrote: Francesco Cattoglio: Wow, they are totally coping! :P What's interesting is not just that Java has type annotations, but the details of this feature. That article show many details. Bye, bearophile I don't think he

Re: Java type annotations, multi-precision

2014-02-09 Thread bearophile
Francesco Cattoglio: Wow, they are totally coping! :P What's interesting is not just that Java has type annotations, but the details of this feature. That article show many details. Bye, bearophile

Re: Java type annotations, multi-precision

2014-02-09 Thread Paulo Pinto
Am 09.02.2014 16:38, schrieb bearophile: Two unrelated things found recently on Reddit: In Java 8 they have added type annotations: http://www.mscharhag.com/2014/02/java-8-type-annotations.html This shows how a C-like language lacks some essential parts to use well the CPUs (both x86 and to

Re: Java type annotations, multi-precision

2014-02-09 Thread Paulo Pinto
Am 09.02.2014 17:23, schrieb Francesco Cattoglio: On Sunday, 9 February 2014 at 15:38:24 UTC, bearophile wrote: Two unrelated things found recently on Reddit: In Java 8 they have added type annotations: http://www.mscharhag.com/2014/02/java-8-type-annotations.html Wow, they are totally

Re: Java type annotations, multi-precision

2014-02-09 Thread Ola Fosheim Grøstad
On Sunday, 9 February 2014 at 16:23:50 UTC, Francesco Cattoglio wrote: Wow, they are totally coping! :P Jokes aside, now I wonder: what language introduced type anotation first? Probably some CASE tool 20-30 years ago or so.

Re: Java type annotations, multi-precision

2014-02-09 Thread Francesco Cattoglio
On Sunday, 9 February 2014 at 15:38:24 UTC, bearophile wrote: Two unrelated things found recently on Reddit: In Java 8 they have added type annotations: http://www.mscharhag.com/2014/02/java-8-type-annotations.html Wow, they are totally coping! :P Jokes aside, now I wonder: what language

Java type annotations, multi-precision

2014-02-09 Thread bearophile
Two unrelated things found recently on Reddit: In Java 8 they have added type annotations: http://www.mscharhag.com/2014/02/java-8-type-annotations.html This shows how a C-like language lacks some essential parts to use well the CPUs (both x86 and to ARM) to implement range integrals or

Re: Two Scala annotations

2012-07-03 Thread Jonathan M Davis
On Tuesday, July 03, 2012 09:42:58 Don Clugston wrote: > On 02/07/12 23:20, Walter Bright wrote: > > On 7/2/2012 1:04 PM, bearophile wrote: > >> Walter Bright: > >>> Put "final" in front of y, and it will compile. Remember, this was > >>> done for D1 > >>> that didn't have const. > >> > >> I see.

Re: Two Scala annotations

2012-07-03 Thread Don Clugston
On 02/07/12 23:20, Walter Bright wrote: On 7/2/2012 1:04 PM, bearophile wrote: Walter Bright: Put "final" in front of y, and it will compile. Remember, this was done for D1 that didn't have const. I see. So in D2 are we going to require that y to be immutable? No. I don't agree there's a p

Re: Two Scala annotations

2012-07-02 Thread Walter Bright
On 7/2/2012 1:04 PM, bearophile wrote: Walter Bright: Put "final" in front of y, and it will compile. Remember, this was done for D1 that didn't have const. I see. So in D2 are we going to require that y to be immutable? No. I don't agree there's a problem. Nor do I care to break existing D

Re: Two Scala annotations

2012-07-02 Thread bearophile
Walter Bright: Put "final" in front of y, and it will compile. Remember, this was done for D1 that didn't have const. I see. So in D2 are we going to require that y to be immutable? Bye, bearophile

Re: Two Scala annotations

2012-07-02 Thread Walter Bright
On 7/2/2012 7:37 AM, bearophile wrote: I have compiled this Java code: class Main { public static void main(String[] args) { int x = 2; int y = 2; switch(x) { case 1: break; case y: break; } } } It gives: Main.java:7: err

Re: Two Scala annotations

2012-07-02 Thread bearophile
Don Clugston: Do you have a reference for this Java behaviour? I did a quick google, and everything I found indicates that case labels must be constants. Thank you for your answer, Don. I have compiled this Java code: class Main { public static void main(String[] args) { int x =

Re: Two Scala annotations

2012-07-02 Thread Don Clugston
ns by mistake)? Calling it a "risk" and "killing" is way, way overstating things. This post is about two Scala annotations. If that's not a bug, is something like that first Scala annotation useful in D too? I don't really see any problem requiring a solution.

Re: Two Scala annotations

2012-06-30 Thread SomeDude
On Sunday, 27 May 2012 at 14:04:48 UTC, Dmitry Olshansky wrote: IMHO if you use annotations for *this* then your language is as good as dead. There are far better things to aim annotations at. I couldn't say it better. @switch might have some utility in rare cases in a language with pa

Re: Two Scala annotations

2012-06-30 Thread Jonathan M Davis
> Was this automatic translation > > desire worth the troubles (like inner classes, > > Yes. > > > like the risk of killing switch optimizations by mistake)? > > Calling it a "risk" and "killing" is way, way overstating things. > > > This pos

Re: Two Scala annotations

2012-06-30 Thread Walter Bright
" and "killing" is way, way overstating things. This post is about two Scala annotations. If that's not a bug, is something like that first Scala annotation useful in D too? I don't really see any problem requiring a solution. If you're working on optimiza

Re: Two Scala annotations

2012-06-30 Thread bearophile
;D translator yet). Was this automatic translation desire worth the troubles (like inner classes, like the risk of killing switch optimizations by mistake)? This post is about two Scala annotations. If that's not a bug, is something like that first Scala annotation useful in D too? Bye, bearophile

Re: Two Scala annotations

2012-06-30 Thread Walter Bright
On 5/27/2012 6:13 AM, bearophile wrote: Currently this D2 code compiles: void main() { int x = 2; int y = 2; switch(x) { case 1: break; case y: break; default: } } I think that accepting that "case y" is a compiler bug, because y is a run-time valu

Case Variables (Re: Two Scala annotations)

2012-06-30 Thread Daniel Murphy
"bearophile" wrote in message news:dkpmzrcoppslcjqvd...@forum.dlang.org... > > Currently this D2 code compiles: > > void main() { > int x = 2; > int y = 2; > switch(x) { > case 1: break; > case y: break; > default: > } > } > > I think that accepting that "c

Re: Two Scala annotations

2012-05-27 Thread bearophile
Alex Rønne Petersen: 1) Any half-decent compiler *will* optimize this thanks to a wide array of standard dataflow analyses. 'y' was meant to be a value unknown at compile-time. I don't know from where people got this crazy idea that a switch statement MUST compile to a jump table *no matter

Re: Two Scala annotations

2012-05-27 Thread Dmitry Olshansky
On 27.05.2012 17:13, bearophile wrote: I have found two Scala annotations. 1) The first one is @switch: http://www.scala-lang.org/api/current/scala/annotation/switch.html Currently this D2 code compiles: void main() { int x = 2; int y = 2; switch(x) { case 1: break; case y: break; default

Re: Two Scala annotations

2012-05-27 Thread Alex Rønne Petersen
On 27-05-2012 15:13, bearophile wrote: I have found two Scala annotations. 1) The first one is @switch: http://www.scala-lang.org/api/current/scala/annotation/switch.html Currently this D2 code compiles: void main() { int x = 2; int y = 2; switch(x) { case 1: break; case y: break; default

Two Scala annotations

2012-05-27 Thread bearophile
I have found two Scala annotations. 1) The first one is @switch: http://www.scala-lang.org/api/current/scala/annotation/switch.html Currently this D2 code compiles: void main() { int x = 2; int y = 2; switch(x) { case 1: break; case y: break; default

Re: Annotations or custom attributes

2012-03-10 Thread Jacob Carlborg
On 2012-03-10 00:23, Andrei Alexandrescu wrote: P.S. Please don't overquote, you systematically do so. Thanks! I'll try to think about that. -- /Jacob Carlborg

Re: Annotations or custom attributes

2012-03-09 Thread Andrei Alexandrescu
On 3/9/12 4:24 PM, Steven Schveighoffer wrote: On Fri, 09 Mar 2012 19:05:00 -0500, Ary Manzana wrote: What are you talking about? Who are you talking to? :) Seriously, though, I think Andrej sometimes quotes *nothing* (no offense for picking on you Andrej), and couple that with the newsgro

Re: Annotations or custom attributes

2012-03-09 Thread Andrej Mitrovic
On 3/10/12, Steven Schveighoffer wrote: > I hope you realize I didn't mean it in a bad/condescending way :) No problemo! I don't take things too seriously around this place (or the internets in general). > But whose fault is it? I'd say it's the technology's fault. A newsgroup seems to be the e

Re: Annotations or custom attributes

2012-03-09 Thread H. S. Teoh
On Fri, Mar 09, 2012 at 08:07:47PM -0500, Steven Schveighoffer wrote: > On Fri, 09 Mar 2012 19:58:37 -0500, H. S. Teoh > wrote: > > >On Fri, Mar 09, 2012 at 07:24:34PM -0500, Steven Schveighoffer wrote: > >>Seriously, though, I think Andrej sometimes quotes *nothing* (no > >>offense for picking o

Re: Annotations or custom attributes

2012-03-09 Thread Steven Schveighoffer
On Fri, 09 Mar 2012 19:58:37 -0500, H. S. Teoh wrote: On Fri, Mar 09, 2012 at 07:24:34PM -0500, Steven Schveighoffer wrote: Seriously, though, I think Andrej sometimes quotes *nothing* (no offense for picking on you Andrej), and couple that with the newsgroup's seemingly random decision to s

Re: Annotations or custom attributes

2012-03-09 Thread Steven Schveighoffer
On Fri, 09 Mar 2012 19:53:29 -0500, Andrej Mitrovic wrote: On 3/10/12, Steven Schveighoffer wrote: Seriously, though, I think Andrej sometimes quotes *nothing* (no offense for picking on you Andrej), and couple that with the newsgroup's seemingly random decision to start a new thread, or

Re: Annotations or custom attributes

2012-03-09 Thread H. S. Teoh
On Fri, Mar 09, 2012 at 07:24:34PM -0500, Steven Schveighoffer wrote: > On Fri, 09 Mar 2012 19:05:00 -0500, Ary Manzana > wrote: > > >What are you talking about? > > Who are you talking to? > > :) > > Seriously, though, I think Andrej sometimes quotes *nothing* (no > offense for picking on you

Re: Annotations or custom attributes

2012-03-09 Thread Andrej Mitrovic
On 3/10/12, Steven Schveighoffer wrote: > Seriously, though, I think Andrej sometimes quotes *nothing* (no offense > for picking on you Andrej), and couple that with the newsgroup's seemingly > random decision to start a new thread, or put a reply at the same level, I > sometimes have no idea what

Re: Annotations or custom attributes

2012-03-09 Thread Steven Schveighoffer
On Fri, 09 Mar 2012 19:05:00 -0500, Ary Manzana wrote: What are you talking about? Who are you talking to? :) Seriously, though, I think Andrej sometimes quotes *nothing* (no offense for picking on you Andrej), and couple that with the newsgroup's seemingly random decision to start a

Re: Annotations or custom attributes

2012-03-09 Thread Ary Manzana
What are you talking about?

Re: Annotations or custom attributes

2012-03-09 Thread Steven Schveighoffer
On Fri, 09 Mar 2012 18:23:17 -0500, Andrei Alexandrescu wrote: On 3/9/12 8:30 AM, Jacob Carlborg wrote: As may serialization library Orange already does: http://dl.dropbox.com/u/18386187/orange_docs/orange.serialization.Serializable.html Look for "NonSerialized". Saw that after posting.

Re: Annotations or custom attributes

2012-03-09 Thread Andrei Alexandrescu
On 3/9/12 8:30 AM, Jacob Carlborg wrote: As may serialization library Orange already does: http://dl.dropbox.com/u/18386187/orange_docs/orange.serialization.Serializable.html Look for "NonSerialized". Saw that after posting. Cool! Andrei P.S. Please don't overquote, you systematically do so

Re: Annotations or custom attributes

2012-03-09 Thread Jonathan M Davis
On Friday, March 09, 2012 16:00:03 Manu wrote: > Okay, so the consensus is, it doesn't currently exist, but there is no real > resistance, and is tentatively planned? > Sounds good to me. I wouldn't really say that it's tentatively planned. I don't recall Walter ever weighing in on it at all, and

Re: Annotations or custom attributes

2012-03-09 Thread Manu
a struct or a class you'll have the same problem, > just at a bigger scale. And it gets worse if you want to annotate templated > types and functions: how can the attribute apply to each instance? > > I'm not saying any of this is impossible using mixins, just that it > bec

Re: Annotations or custom attributes

2012-03-09 Thread Michel Fortin
On 2012-03-09 16:15:30 +, Andrei Alexandrescu said: I think a good approach in D would be to define mixins that work in conjunction with the feature involved, for example: class A { int thing; mixin(DoNotSerialize!"thing"); ... } or together: class A { mixin(DoNotSe

Re: Annotations or custom attributes

2012-03-09 Thread Manu
On 9 March 2012 18:15, Andrei Alexandrescu wrote: > On 3/9/12 2:56 AM, Manu wrote: > >> Does D have a nice way to add annotations or custom attributes to >> entities? >> >> In Java/C# for example, it is common to annotate things with useful >> compile time in

Re: Annotations or custom attributes

2012-03-09 Thread Jacob Carlborg
On 2012-03-09 17:15, Andrei Alexandrescu wrote: On 3/9/12 2:56 AM, Manu wrote: Does D have a nice way to add annotations or custom attributes to entities? In Java/C# for example, it is common to annotate things with useful compile time information. I'd like to be able to do that in

Re: Annotations or custom attributes

2012-03-09 Thread Gor Gyolchanyan
That's easy to implement and extremely ugly. On Fri, Mar 9, 2012 at 8:15 PM, Andrei Alexandrescu wrote: > On 3/9/12 2:56 AM, Manu wrote: >> >> Does D have a nice way to add annotations or custom attributes to >> entities? >> >> In Java/C# for example, it is

Re: Annotations or custom attributes

2012-03-09 Thread Andrei Alexandrescu
On 3/9/12 2:56 AM, Manu wrote: Does D have a nice way to add annotations or custom attributes to entities? In Java/C# for example, it is common to annotate things with useful compile time information. I'd like to be able to do that in D on occasion. For instance, I'm serialising s

Re: Annotations or custom attributes

2012-03-09 Thread Manu
On 9 March 2012 17:20, bearophile wrote: > Manu: > > > Okay, so the consensus is, it doesn't currently exist, but there is no >> real >> resistance, and is tentatively planned? >> Sounds good to me. >> > > As far as I know there are no concrete ideas yet for the semantics and > precise usage of

Re: Annotations or custom attributes

2012-03-09 Thread bearophile
Manu: Okay, so the consensus is, it doesn't currently exist, but there is no real resistance, and is tentatively planned? Sounds good to me. As far as I know there are no concrete ideas yet for the semantics and precise usage of this feature. And I think there are different ideas regarding

Re: Annotations or custom attributes

2012-03-09 Thread Manu
Okay, so the consensus is, it doesn't currently exist, but there is no real resistance, and is tentatively planned? Sounds good to me. On 9 March 2012 15:42, Dmitry Olshansky wrote: > On 09.03.2012 14:56, Manu wrote: > >> Does D have a nice way to add annotations or cus

Re: Annotations or custom attributes

2012-03-09 Thread Dmitry Olshansky
On 09.03.2012 14:56, Manu wrote: Does D have a nice way to add annotations or custom attributes to entities? There is a potential for them. At least technically everything with @ in front of it was supposed to be an annotation (like @property). I think it's just, sort of, reserved for f

Re: Annotations or custom attributes

2012-03-09 Thread Jacob Carlborg
On 2012-03-09 11:56, Manu wrote: Does D have a nice way to add annotations or custom attributes to entities? Unfortunately no. In Java/C# for example, it is common to annotate things with useful compile time information. I'd like to be able to do that in D on occasion. For instance

Re: Annotations or custom attributes

2012-03-09 Thread Alex Rønne Petersen
On 09-03-2012 11:56, Manu wrote: Does D have a nice way to add annotations or custom attributes to entities? Unfortunately, no. In Java/C# for example, it is common to annotate things with useful compile time information. I'd like to be able to do that in D on occasion. Yes. This

Annotations or custom attributes

2012-03-09 Thread Manu
Does D have a nice way to add annotations or custom attributes to entities? In Java/C# for example, it is common to annotate things with useful compile time information. I'd like to be able to do that in D on occasion. For instance, I'm serialising some struct/class using reflection to

Re: Idea for @annotations

2011-08-13 Thread soywiz
I really like the idea of annotations to use in traits (compile-time-pseudoreflection). I have the following code: http://code.google.com/p/pspemu/source/browse/trunk/src/pspemu/hle/kd/rtc/sceRtc.d Each function has associated a NID. And I have to specify the NID outside, repeating the name of

Re: Idea for @annotations

2011-08-01 Thread bearophile
%u: > An idea for a potential use of annotations: In my mind the main purpose of user-defined annotations is to allow the user to write small (scoped) extensions to the type system. But Python-style annotations too are useful. Bye, bearophile

Re: Idea for @annotations

2011-08-01 Thread Mehrdad
dea for a potential use of annotations: How about being able to annotate _anything_ with a template? What problem does this solve? Is it just syntax sugar? If so, is it worth complicating the language even more for this convenience? (1) It's beautiful! (2) It documents the fact that you&

Re: Idea for @annotations

2011-08-01 Thread Jacob Carlborg
On 2011-08-01 09:00, KennyTM~ wrote: On Aug 1, 11 13:42, %u wrote: An idea for a potential use of annotations: How about being able to annotate _anything_ with a template? It would be the equivalent of Python's annotations: the template's first parameter would be an alias to the t

Re: Idea for @annotations

2011-08-01 Thread Jacob Carlborg
On 2011-08-01 07:42, %u wrote: An idea for a potential use of annotations: How about being able to annotate _anything_ with a template? It would be the equivalent of Python's annotations: the template's first parameter would be an alias to the thing being annotated, and its return v

Re: Idea for @annotations

2011-08-01 Thread Peter Alexander
On 1/08/11 6:42 AM, %u wrote: An idea for a potential use of annotations: How about being able to annotate _anything_ with a template? What problem does this solve? Is it just syntax sugar? If so, is it worth complicating the language even more for this convenience?

Re: Idea for @annotations

2011-08-01 Thread KennyTM~
On Aug 1, 11 13:42, %u wrote: An idea for a potential use of annotations: How about being able to annotate _anything_ with a template? It would be the equivalent of Python's annotations: the template's first parameter would be an alias to the thing being annotated, and its return v

Idea for @annotations

2011-07-31 Thread %u
An idea for a potential use of annotations: How about being able to annotate _anything_ with a template? It would be the equivalent of Python's annotations: the template's first parameter would be an alias to the thing being annotated, and its return value would be the code generate

Re: User Defined Annotations

2011-03-11 Thread Andrew Wiley
wondering what it would take to move forward with >> getting user defined annotations into the language, and whether it >> would be feasible for D2. Would the next step be to make a full >> proposal? > > For this to be useful that language would probably need better reflecti

Re: User Defined Annotations

2011-03-10 Thread Jacob Carlborg
On 2011-03-11 04:30, Andrew Wiley wrote: This is a topic that seems to come up every so often (well, I bring it up every so often, but I haven't really heard negative remarks about it), and I was wondering what it would take to move forward with getting user defined annotations into the lan

Re: User Defined Annotations

2011-03-10 Thread bearophile
Andrew Wiley: > Would the next step be to make a full proposal? Creating a pre-D Enhancement Proposal (pre-DEP) is good. Bye, bearophile

User Defined Annotations

2011-03-10 Thread Andrew Wiley
This is a topic that seems to come up every so often (well, I bring it up every so often, but I haven't really heard negative remarks about it), and I was wondering what it would take to move forward with getting user defined annotations into the language, and whether it would be feasible f

Re: Annotations

2009-07-28 Thread Andrei Alexandrescu
Kagamin wrote: Andrei Alexandrescu Wrote: What prevents us from doing more generic annotations with syntax like @property? Walter. No one's been able to convince him they're useful. Then someone better put forward a good argument. .Net framework is one big good argument, her

Annotations

2009-07-28 Thread Kagamin
Andrei Alexandrescu Wrote: > >> What prevents us from doing > >> more generic annotations with syntax like @property? > >> > > > > Walter. No one's been able to convince him they're useful. > > Then someone better put forward a good argum

Re: Idea For Attributes/Annotations

2009-03-10 Thread Daniel Keep
On the syntax for D, a few thoughts: In Python, the decorator expression must evaluate to a function, which is then called with the function being decorated. We could do something similar in D. Let's change the syntax to this for now: @(expr) decl Let's assume that expr must be a template. T

Re: Idea For Attributes/Annotations

2009-03-10 Thread Daniel Keep
For reference, Python has a concept called decorators. Take this function: > def trace(fn): > def __wrap(*pargs,**kwargs): > print 'IN %s' % fn.__name__ > r = fn(*pargs,**kwargs) > print 'OUT %s' % fn.__name__ > return r > > return __wrap And use it like

Re: Idea For Attributes/Annotations

2009-03-10 Thread Nick Sabalausky
t;, enumToString (s)); > - > Ok, so apparently D2 phobos already has this in std.typecons (saw that in a reply over at ".D.learn"), but the main point of my post still remains. That point being, it looks terrible and annotations could make it (and anything similar) look not-terrible.

Idea For Attributes/Annotations

2009-03-10 Thread Nick Sabalausky
I've previously voiced my desire for something similar to C#'s attributes (annotations in Java, IIRC), but that kind of got sidetracked into a discussion of command line parsers. I have another idea of a type of scenario where something like this would be very nice, and it also ties