* Implicit dereferences rational question @ 2014-05-18 15:24 Victor Porton 2014-05-18 17:08 ` Robert A Duff 0 siblings, 1 reply; 8+ messages in thread From: Victor Porton @ 2014-05-18 15:24 UTC (permalink / raw) Why implicit dereferences use only access discriminants, not arbitrary access fields? -- Victor Porton - http://portonvictor.org ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Implicit dereferences rational question 2014-05-18 15:24 Implicit dereferences rational question Victor Porton @ 2014-05-18 17:08 ` Robert A Duff 2014-05-18 19:22 ` Victor Porton 0 siblings, 1 reply; 8+ messages in thread From: Robert A Duff @ 2014-05-18 17:08 UTC (permalink / raw) Victor Porton <porton@narod.ru> writes: > Why implicit dereferences use only access discriminants, not arbitrary > access fields? It helps prevent dangling pointers. - Bob ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Implicit dereferences rational question 2014-05-18 17:08 ` Robert A Duff @ 2014-05-18 19:22 ` Victor Porton 2014-05-19 21:51 ` Randy Brukardt 0 siblings, 1 reply; 8+ messages in thread From: Victor Porton @ 2014-05-18 19:22 UTC (permalink / raw) Robert A Duff wrote: > Victor Porton <porton@narod.ru> writes: > >> Why implicit dereferences use only access discriminants, not arbitrary >> access fields? > > It helps prevent dangling pointers. In which way limiting to discriminants may prevent dangling pointers? -- Victor Porton - http://portonvictor.org ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Implicit dereferences rational question 2014-05-18 19:22 ` Victor Porton @ 2014-05-19 21:51 ` Randy Brukardt 2014-05-19 22:44 ` Robert A Duff 2014-05-20 7:29 ` Dmitry A. Kazakov 0 siblings, 2 replies; 8+ messages in thread From: Randy Brukardt @ 2014-05-19 21:51 UTC (permalink / raw) "Victor Porton" <porton@narod.ru> wrote in message news:llb1aa$gth$1@speranza.aioe.org... > Robert A Duff wrote: >> Victor Porton <porton@narod.ru> writes: >> >>> Why implicit dereferences use only access discriminants, not arbitrary >>> access fields? >> >> It helps prevent dangling pointers. > > In which way limiting to discriminants may prevent dangling pointers? Discriminants have a lengthy set of accessibility rules, which turn out to be exactly what's needed for limiting dangling pointers. In particular, it's almost never the case that one can make a copy of an access discriminant, while that's easy for a "arbitrary access field". Randy. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Implicit dereferences rational question 2014-05-19 21:51 ` Randy Brukardt @ 2014-05-19 22:44 ` Robert A Duff 2014-05-20 7:29 ` Dmitry A. Kazakov 1 sibling, 0 replies; 8+ messages in thread From: Robert A Duff @ 2014-05-19 22:44 UTC (permalink / raw) "Randy Brukardt" <randy@rrsoftware.com> writes: > "Victor Porton" <porton@narod.ru> wrote in message > news:llb1aa$gth$1@speranza.aioe.org... >> Robert A Duff wrote: >>> Victor Porton <porton@narod.ru> writes: >>> >>>> Why implicit dereferences use only access discriminants, not arbitrary >>>> access fields? >>> >>> It helps prevent dangling pointers. >> >> In which way limiting to discriminants may prevent dangling pointers? > > Discriminants have a lengthy set of accessibility rules, which turn out to > be exactly what's needed for limiting dangling pointers. In particular, it's > almost never the case that one can make a copy of an access discriminant, > while that's easy for a "arbitrary access field". Right; thanks, Randy. Victor, I suggest you try to create dangling pointers via those operations that return things with access discriminants. When you see the error messages from the compiler, you will likely understand why it's hard to create dangling pointers by accident. An alternative is to read and understand the accessibility rules. That's quite hard work! And note that a discriminant of a named access type is not an "access discriminant"; the access type has to be anonymous for the special accessibility rules to kick in. - Bob ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Implicit dereferences rational question 2014-05-19 21:51 ` Randy Brukardt 2014-05-19 22:44 ` Robert A Duff @ 2014-05-20 7:29 ` Dmitry A. Kazakov 2014-05-20 21:26 ` Randy Brukardt 1 sibling, 1 reply; 8+ messages in thread From: Dmitry A. Kazakov @ 2014-05-20 7:29 UTC (permalink / raw) On Mon, 19 May 2014 16:51:56 -0500, Randy Brukardt wrote: > "Victor Porton" <porton@narod.ru> wrote in message > news:llb1aa$gth$1@speranza.aioe.org... >> Robert A Duff wrote: >>> Victor Porton <porton@narod.ru> writes: >>> >>>> Why implicit dereferences use only access discriminants, not arbitrary >>>> access fields? >>> >>> It helps prevent dangling pointers. >> >> In which way limiting to discriminants may prevent dangling pointers? > > Discriminants have a lengthy set of accessibility rules, which turn out to > be exactly what's needed for limiting dangling pointers. In particular, it's > almost never the case that one can make a copy of an access discriminant, > while that's easy for a "arbitrary access field". Except that dereference, be it implicit or explicit, does not create pointers. Obviously, it eliminates a pointer, as the name suggests. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Implicit dereferences rational question 2014-05-20 7:29 ` Dmitry A. Kazakov @ 2014-05-20 21:26 ` Randy Brukardt 2014-05-21 7:36 ` Dmitry A. Kazakov 0 siblings, 1 reply; 8+ messages in thread From: Randy Brukardt @ 2014-05-20 21:26 UTC (permalink / raw) "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message news:1pkkrdwu7lh6y.7cjyncdfw33e.dlg@40tude.net... > On Mon, 19 May 2014 16:51:56 -0500, Randy Brukardt wrote: > >> "Victor Porton" <porton@narod.ru> wrote in message >> news:llb1aa$gth$1@speranza.aioe.org... >>> Robert A Duff wrote: >>>> Victor Porton <porton@narod.ru> writes: >>>> >>>>> Why implicit dereferences use only access discriminants, not arbitrary >>>>> access fields? >>>> >>>> It helps prevent dangling pointers. >>> >>> In which way limiting to discriminants may prevent dangling pointers? >> >> Discriminants have a lengthy set of accessibility rules, which turn out >> to >> be exactly what's needed for limiting dangling pointers. In particular, >> it's >> almost never the case that one can make a copy of an access discriminant, >> while that's easy for a "arbitrary access field". > > Except that dereference, be it implicit or explicit, does not create > pointers. Obviously, it eliminates a pointer, as the name suggests. I suppose, but you have to have a pointer or something very similar to a pointer if you want to be able to write to it. And that's the key feature here: that one can use these as variables as well as constants. It didn't make much sense to invent a new, almost pointer construct just for this purpose when we already had one with the correct semantics. Randy. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Implicit dereferences rational question 2014-05-20 21:26 ` Randy Brukardt @ 2014-05-21 7:36 ` Dmitry A. Kazakov 0 siblings, 0 replies; 8+ messages in thread From: Dmitry A. Kazakov @ 2014-05-21 7:36 UTC (permalink / raw) On Tue, 20 May 2014 16:26:08 -0500, Randy Brukardt wrote: > "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message > news:1pkkrdwu7lh6y.7cjyncdfw33e.dlg@40tude.net... >> On Mon, 19 May 2014 16:51:56 -0500, Randy Brukardt wrote: >> >>> "Victor Porton" <porton@narod.ru> wrote in message >>> news:llb1aa$gth$1@speranza.aioe.org... >>>> Robert A Duff wrote: >>>>> Victor Porton <porton@narod.ru> writes: >>>>> >>>>>> Why implicit dereferences use only access discriminants, not arbitrary >>>>>> access fields? >>>>> >>>>> It helps prevent dangling pointers. >>>> >>>> In which way limiting to discriminants may prevent dangling pointers? >>> >>> Discriminants have a lengthy set of accessibility rules, which turn out >>> to >>> be exactly what's needed for limiting dangling pointers. In particular, >>> it's >>> almost never the case that one can make a copy of an access discriminant, >>> while that's easy for a "arbitrary access field". >> >> Except that dereference, be it implicit or explicit, does not create >> pointers. Obviously, it eliminates a pointer, as the name suggests. > > I suppose, but you have to have a pointer or something very similar to a > pointer if you want to be able to write to it. Actually not. Most pointers and pointer-like objects are initialized once and never change. But this still has nothing to do with implicit dereference, or more precisely with delegation of operations through composition with X.all. > And that's the key feature > here: that one can use these as variables as well as constants. It didn't > make much sense to invent a new, almost pointer construct just for this > purpose when we already had one with the correct semantics. Of course it does. So many projects and practically all bindings require smart pointers, handles and other user-defined referential objects in some or other form. It is about language design principles. Programmers want to control the semantics of referential types. Ada tried to enforce a certain semantics on them in the ugly form of incomprehensible accessibility rules. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-05-21 7:36 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2014-05-18 15:24 Implicit dereferences rational question Victor Porton 2014-05-18 17:08 ` Robert A Duff 2014-05-18 19:22 ` Victor Porton 2014-05-19 21:51 ` Randy Brukardt 2014-05-19 22:44 ` Robert A Duff 2014-05-20 7:29 ` Dmitry A. Kazakov 2014-05-20 21:26 ` Randy Brukardt 2014-05-21 7:36 ` Dmitry A. Kazakov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox