* A question about syntax or semantics @ 2014-05-17 22:56 Victor Porton 2014-05-17 23:05 ` Bill Findlay ` (2 more replies) 0 siblings, 3 replies; 11+ messages in thread From: Victor Porton @ 2014-05-17 22:56 UTC (permalink / raw) From Ada2012 Reference Manual: arm2012.html/rm-4-1-3.html [[[ A selected_component that is not an expanded name shall resolve to denote one of the following: A view of a subprogram whose first formal parameter is of a tagged type or is an access parameter whose designated type is tagged: ]]] Why it is significant to have it only for the first formal parameter? Please explain with examples. -- Victor Porton - http://portonvictor.org ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: A question about syntax or semantics 2014-05-17 22:56 A question about syntax or semantics Victor Porton @ 2014-05-17 23:05 ` Bill Findlay 2014-05-18 2:47 ` Brad Moore 2014-05-19 17:02 ` Adam Beneschan 2 siblings, 0 replies; 11+ messages in thread From: Bill Findlay @ 2014-05-17 23:05 UTC (permalink / raw) On 17/05/2014 23:56, in article ll8peq$96q$1@speranza.aioe.org, "Victor Porton" <porton@narod.ru> wrote: > From Ada2012 Reference Manual: > > arm2012.html/rm-4-1-3.html > > [[[ > A selected_component that is not an expanded name shall resolve to denote > one of the following: > > A view of a subprogram whose first formal parameter is of a tagged type > or is an access parameter whose designated type is tagged: > ]]] > > Why it is significant to have it only for the first formal parameter? > > Please explain with examples. "if you are are a homosexualist you will be transformed into a natural" Please explain with examples. -- Bill Findlay with blueyonder.co.uk; use surname & forename; ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: A question about syntax or semantics 2014-05-17 22:56 A question about syntax or semantics Victor Porton 2014-05-17 23:05 ` Bill Findlay @ 2014-05-18 2:47 ` Brad Moore 2014-05-18 10:48 ` Simon Wright 2014-05-19 17:02 ` Adam Beneschan 2 siblings, 1 reply; 11+ messages in thread From: Brad Moore @ 2014-05-18 2:47 UTC (permalink / raw) On 14-05-17 04:56 PM, Victor Porton wrote: > From Ada2012 Reference Manual: > > arm2012.html/rm-4-1-3.html > > [[[ > A selected_component that is not an expanded name shall resolve to denote > one of the following: > > A view of a subprogram whose first formal parameter is of a tagged type > or is an access parameter whose designated type is tagged: > ]]] > > Why it is significant to have it only for the first formal parameter? > > Please explain with examples. > > This question is worded like an exam question, so rather than give the answer directly, I'll respond with another question that might shed some light on your question. with Ada.Containers.Doubly_Linked_Lists; procedure X is package Integer_Lists is new Ada.Containers.Doubly_Linked_Lists (Element_Type => Integer); List1, List2 : Integer_Lists.List; begin List1.Append(1); List2.Append(2); List1.Move(List2); end; If we didn't have the rule that you are asking about, what could we say about the Move call in the example above? Which list is the Source, and which list is the Target parameter? Is List1 getting moved into List2, or is it the other way around? Brad ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: A question about syntax or semantics 2014-05-18 2:47 ` Brad Moore @ 2014-05-18 10:48 ` Simon Wright 2014-05-18 14:40 ` [OT] Assembly language syntax, was: " Simon Clubley 0 siblings, 1 reply; 11+ messages in thread From: Simon Wright @ 2014-05-18 10:48 UTC (permalink / raw) Brad Moore <brad.moore@shaw.ca> writes: > On 14-05-17 04:56 PM, Victor Porton wrote: >> From Ada2012 Reference Manual: >> >> arm2012.html/rm-4-1-3.html >> >> [[[ >> A selected_component that is not an expanded name shall resolve to denote >> one of the following: >> >> A view of a subprogram whose first formal parameter is of a tagged type >> or is an access parameter whose designated type is tagged: >> ]]] >> >> Why it is significant to have it only for the first formal parameter? >> >> Please explain with examples. >> >> > > This question is worded like an exam question, so rather than give the > answer directly, I'll respond with another question that might shed > some light on your question. > > with Ada.Containers.Doubly_Linked_Lists; > > procedure X is > package Integer_Lists is new > Ada.Containers.Doubly_Linked_Lists (Element_Type => Integer); > List1, List2 : Integer_Lists.List; > begin > List1.Append(1); > List2.Append(2); > > List1.Move(List2); > end; > > If we didn't have the rule that you are asking about, what could we > say about the Move call in the example above? Which list is the > Source, and which list is the Target parameter? Is List1 getting moved > into List2, or is it the other way around? Well, considering the various assembler languages around, I'd still be confused but for different reasons: given "mov r0,r1" does r1 receive the value in r0 (which is what I'd expect, my first encounter with a 'normal' assembler having been MACRO-32) or does r0 receive the value in r1? ^ permalink raw reply [flat|nested] 11+ messages in thread
* [OT] Assembly language syntax, was: Re: A question about syntax or semantics 2014-05-18 10:48 ` Simon Wright @ 2014-05-18 14:40 ` Simon Clubley 2014-05-18 14:50 ` Simon Wright 0 siblings, 1 reply; 11+ messages in thread From: Simon Clubley @ 2014-05-18 14:40 UTC (permalink / raw) On 2014-05-18, Simon Wright <simon@pushface.org> wrote: > > Well, considering the various assembler languages around, I'd still be > confused but for different reasons: given "mov r0,r1" does r1 receive > the value in r0 (which is what I'd expect, my first encounter with a > 'normal' assembler having been MACRO-32) or does r0 receive the value in > r1? On ARM, with the binutils assembler, it's the other way around. BTW, "mov src, dest" versus "mov dest, src" is an attribute of the assembler in use, not the architecture. A very good example would be the gas versus Intel syntax for x86. Same architecture, different assembler syntax. Simon. -- Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP Microsoft: Bringing you 1980s technology to a 21st century world ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [OT] Assembly language syntax, was: Re: A question about syntax or semantics 2014-05-18 14:40 ` [OT] Assembly language syntax, was: " Simon Clubley @ 2014-05-18 14:50 ` Simon Wright 0 siblings, 0 replies; 11+ messages in thread From: Simon Wright @ 2014-05-18 14:50 UTC (permalink / raw) Simon Clubley <clubley@remove_me.eisner.decus.org-Earth.UFP> writes: > On 2014-05-18, Simon Wright <simon@pushface.org> wrote: >> >> Well, considering the various assembler languages around, I'd still >> be confused but for different reasons: given "mov r0,r1" does r1 >> receive the value in r0 (which is what I'd expect, my first encounter >> with a 'normal' assembler having been MACRO-32) or does r0 receive >> the value in r1? > > On ARM, with the binutils assembler, it's the other way around. Um, I mentioned both possibilities. > BTW, "mov src, dest" versus "mov dest, src" is an attribute of the > assembler in use, not the architecture. Yes. > A very good example would be the gas versus Intel syntax for x86. > Same architecture, different assembler syntax. Yes. You've made the point I was trying to make rather more clearly than I managed to, I think! ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: A question about syntax or semantics 2014-05-17 22:56 A question about syntax or semantics Victor Porton 2014-05-17 23:05 ` Bill Findlay 2014-05-18 2:47 ` Brad Moore @ 2014-05-19 17:02 ` Adam Beneschan 2014-05-19 21:35 ` Randy Brukardt 2 siblings, 1 reply; 11+ messages in thread From: Adam Beneschan @ 2014-05-19 17:02 UTC (permalink / raw) On Saturday, May 17, 2014 3:56:20 PM UTC-7, Victor Porton wrote: > From Ada2012 Reference Manual: > > arm2012.html/rm-4-1-3.html > [[[ > A selected_component that is not an expanded name shall resolve to denote > one of the following: > > A view of a subprogram whose first formal parameter is of a tagged type > or is an access parameter whose designated type is tagged: > ]]] > > Why it is significant to have it only for the first formal parameter? > > Please explain with examples. Well, this thread took some pretty bizarre turns, for reasons I don't understand. This looks more like a "why did the language designers do it this way" question than an exam question to me, so I'll try to answer (note: I'm not one of the language designers). Ada 95 introduced object-oriented concepts into the language by using tagged types. However, unlike other OO languages, in which an "instance method" is thought of as primarily applying to a certain object, which is then treated specially in the syntax of a method call (contrasted with any other objects that might be passed as parameters), Ada 95 treated the "instance" as a parameter just like all the other parameters. (There can be more than one parameter of the same tagged type; if dispatching, i.e. polymorphism, takes place, the language requires that all such parameters have the same type. So there's no question about which parameter is "preferred" when deciding which subprogram is actually called.) However, this led to problems. From AI95-252: "This one was prompted in part by the reactions of Erhard's grad students to the difficulty of having to both identify the package containing an operation and the object on which the operation is to be performed. With both classwide and primitive operations being relevant, and these operations having essentially opposite rules about which package the operation resides in (the ultimate ancestor for classwide, and the ultimate descendant for primitive), some way to eliminate the package from the syntax seemed useful. "The other prompting factor is the continual whining that Ada 95 is out of the mainstream of OOP languages because it lacks the object.operation syntax. This proposal defines the 'object.op' syntax as essentially a syntactic sugar on the pkg.op(object,...) syntax. This approach is pretty much what Modula-3 did. It provides for a 'symmetric' notation when dealing with binary operators, while also providing an 'asymmetric' (object-oriented) syntax when using operations that have a single controlling operand." (http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00252.txt?rev=1.16) So when they added this feature to Ada 2005, Ada already had subprograms that would take an object of the tagged type as a parameter (and would dispatch if necessary), and their intent was to provide a new syntax on top of the existing feature to allow for an Object.Operation(...) notation, rather than add a whole new "instance method" concept, which would have been unnecessary. So given that Object.Operation was going to be a new syntax to refer to an existing type of subprogram call, I think tying the "Object" to the first parameter of an existing subprogram was the only reasonable solution. First, as Brad pointed out, you have to deal with operations with more than one parameter of the type: procedure Operation (X1, X2 : Some_Tagged_Type); You can't really allow both X1.Operation(X2) and X2.Operation(X1) as two different ways to specify a call to Operation(X1, X2). That would be ambiguous. Another possibility would be to let the declaration of Operation specify which of its parameters should be used as the parameter of interest in an Object.Operation call. But I think that would have made things really complex. Finally, they could have decided that the *first* *tagged* parameter of any operation would be the one used for Object.Operation notation, so that procedure Operation (P1 : Integer; P2 : Some_Tagged_Type; P3 : Integer); could be called like X : Some_Tagged_Type; X.Operation(100, 200); which would be equivalent to Operation(100, X, 200); But I think that would have caused a lot of extra work both for language designers and for compiler implementors, for very little gain. I suspect that most Ada 95 programs were already putting the tagged object of interest first in their parameter lists anyway (that's just a guess, though; I don't really have any evidence). Anyway, I hope that answers the question of why it's important to have the feature for the first parameter only. -- Adam > > > > > > -- > > Victor Porton - http://portonvictor.org ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: A question about syntax or semantics 2014-05-19 17:02 ` Adam Beneschan @ 2014-05-19 21:35 ` Randy Brukardt 2014-05-19 22:05 ` Bill Findlay 2014-05-19 22:58 ` Robert A Duff 0 siblings, 2 replies; 11+ messages in thread From: Randy Brukardt @ 2014-05-19 21:35 UTC (permalink / raw) "Adam Beneschan" <adambeneschan@gmail.com> wrote in message news:79ced891-4a1a-4008-ade8-875228e5dc03@googlegroups.com... On Saturday, May 17, 2014 3:56:20 PM UTC-7, Victor Porton wrote: ... >> Why it is significant to have it only for the first formal parameter? >> >> Please explain with examples. > >Well, this thread took some pretty bizarre turns, for reasons I don't >understand. (1) It's mid-May - aka, Finals time. (2) The question is believable, but the "please explain with examples" is a weird demand; it doesn't seem to relate to the question. The only place I'd expect such a demand is in an essay question in an exam. >This looks more like a "why did the language designers do it this way" >question than an exam question to me... Could be. But is there any other sane choice? I don't think we (the ARG, aka the language designers) spent 1 minute on any other possible meaning of this construct. (Some of the details, like tagged-only versus any type, took a lot longer, and how to describe it in the standard was tricky, but there never was any doubt about the basic meaning.) I'm actually quite surprised that you managed to think of other possible meanings and make them sound semi-plausible. :-) Ergo (3), the question seems contrived, since there isn't any other sensible option. That's more of a characteristic of an exam question than a real question. Of course, we all could be wrong. You've done a fine job of answering the question in that case. Randy. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: A question about syntax or semantics 2014-05-19 21:35 ` Randy Brukardt @ 2014-05-19 22:05 ` Bill Findlay 2014-05-19 22:58 ` Robert A Duff 1 sibling, 0 replies; 11+ messages in thread From: Bill Findlay @ 2014-05-19 22:05 UTC (permalink / raw) On 19/05/2014 22:35, in article lldtft$3su$1@loke.gir.dk, "Randy Brukardt" <randy@rrsoftware.com> wrote: > "Adam Beneschan" <adambeneschan@gmail.com> wrote in message > news:79ced891-4a1a-4008-ade8-875228e5dc03@googlegroups.com... > On Saturday, May 17, 2014 3:56:20 PM UTC-7, Victor Porton wrote: > ... > >>> Why it is significant to have it only for the first formal parameter? >>> >>> Please explain with examples. >> >> Well, this thread took some pretty bizarre turns, for reasons I don't >> understand. > > (1) It's mid-May - aka, Finals time. ? Porton is no undergraduate, if his website is to be believed. He used a c.l.a. post to publicise the latter, which promotes his religion-based homophobia. -- Bill Findlay with blueyonder.co.uk; use surname & forename; ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: A question about syntax or semantics 2014-05-19 21:35 ` Randy Brukardt 2014-05-19 22:05 ` Bill Findlay @ 2014-05-19 22:58 ` Robert A Duff 2014-05-20 8:01 ` Georg Bauhaus 1 sibling, 1 reply; 11+ messages in thread From: Robert A Duff @ 2014-05-19 22:58 UTC (permalink / raw) "Randy Brukardt" <randy@rrsoftware.com> writes: > Ergo (3), the question seems contrived, since there isn't any other sensible > option. That's more of a characteristic of an exam question than a real > question. It seems pretty stupid, as an exam question. I mean, the answer is, "Nothing else makes sense." (which Adam explored in detail). I'd be tempted to answer with a challenge: "How would _you_ do it?", which isn't a good way to pass an exam. ;-) - Bob ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: A question about syntax or semantics 2014-05-19 22:58 ` Robert A Duff @ 2014-05-20 8:01 ` Georg Bauhaus 0 siblings, 0 replies; 11+ messages in thread From: Georg Bauhaus @ 2014-05-20 8:01 UTC (permalink / raw) On 20/05/14 00:58, Robert A Duff wrote: > I mean, the answer is, > "Nothing else makes sense." One could write (Foo, Bar).Operation (Baz); if Dmitry is to be believed. ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2014-05-20 8:01 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2014-05-17 22:56 A question about syntax or semantics Victor Porton 2014-05-17 23:05 ` Bill Findlay 2014-05-18 2:47 ` Brad Moore 2014-05-18 10:48 ` Simon Wright 2014-05-18 14:40 ` [OT] Assembly language syntax, was: " Simon Clubley 2014-05-18 14:50 ` Simon Wright 2014-05-19 17:02 ` Adam Beneschan 2014-05-19 21:35 ` Randy Brukardt 2014-05-19 22:05 ` Bill Findlay 2014-05-19 22:58 ` Robert A Duff 2014-05-20 8:01 ` Georg Bauhaus
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox