Suffix _T for types found good

This is a discussion on Suffix _T for types found good within the ADA forums in Programming Languages category; On Wed, 20 Aug 2008 13:37:03 -0700 (PDT), Adam Beneschan wrote: > On Aug 20, 8:38 am, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de> > wrote: >> On Wed, 20 Aug 2008 07:25:12 -0700 (PDT), Adam Beneschan wrote: >>> Yeah, earlier on in this thread I was thinking about whether it would >>> have been possible for Ada to have separate namespaces for types and >>> other non-type entities without ambiguities. Attributes make this >>> impossible. >> >> Nope. In all cases the type and variable names can be overloaded. Any >> difference between them is not lexical. > > Apparently I didn't ...

Go Back   Application Development Forum > Programming Languages > ADA

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #61  
Old 08-21-2008, 05:44 AM
Dmitry A. Kazakov
Guest
 
Default Re: Suffix _T for types found good

On Wed, 20 Aug 2008 13:37:03 -0700 (PDT), Adam Beneschan wrote:

> On Aug 20, 8:38 am, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
> wrote:
>> On Wed, 20 Aug 2008 07:25:12 -0700 (PDT), Adam Beneschan wrote:
>>> Yeah, earlier on in this thread I was thinking about whether it would
>>> have been possible for Ada to have separate namespaces for types and
>>> other non-type entities without ambiguities. Attributes make this
>>> impossible.

>>
>> Nope. In all cases the type and variable names can be overloaded. Any
>> difference between them is not lexical.

>
> Apparently I didn't make myself clear, since we seem to be talking
> about two totally different things. Either that, or I just don't
> understand what you're saying.
>
> Let me try to make myself clearer: If there were a rule change in Ada
> so that types (or subtypes) could have the same identifiers as other
> entities in the same scope, in many or most cases the compiler could
> unambiguously determine from context whether the identifier refers to
> the type:
>
> XYZ : Some_Type;
> type XYZ is array (1..10) of Some_Other_Type;
> An_Object : XYZ;
>
> In this last line, it's clear that only the type declaration could be
> meant by XYZ. But in attribute cases, it can be ambiguous: XYZ'First,
> XYZ'Last, XYZ'Size, probably some others. So that aspect of the
> language would need a new design. I'm not sure whether there are
> other cases, besides attributes, where the identifier would be
> ambiguous.


My point is that this does not differ from the case when XYZ are two
variables visible from two different packages:

package A is
XYZ : Some_Type;
end A;

package B is
XYZ : Some_Type;
end B;

use A, B and XYZ'First will be ambiguous. It is not a lexical problem.
S'First is just an expression it might be ambiguous. So what?

The real problem is that the ambiguity might be impossible to resolve. But
this isn't new. There already exist cases when names get hidden forever.

So long types are not first-class citizens in Ada, we could have a
different namespace for them. Not that I would advocate for that!

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
Reply With Quote
  #62  
Old 08-21-2008, 05:47 AM
Stephen Leake
Guest
 
Default Re: Suffix _T for types found good

"Peter C. Chapin" <pcc482719@gmail.com> writes:

> Adam Beneschan wrote:
>
>> XYZ : Some_Type;
>> type XYZ is array (1..10) of Some_Other_Type;
>> An_Object : XYZ;
>>
>> In this last line, it's clear that only the type declaration could be
>> meant by XYZ.

>
> I'm not sure allowing such a thing, even if were possible, would be a
> good idea. Types and instances are conceptually quite different and
> allowing them to reuse the same name (in the same scope) sounds
> confusing. After all, a set of integers is different than any particular
> integer and I don't want to loose sight of that when I'm looking at my code.


The set is after the colon, the particular is before it. Most of the
time it is clear from context.

Except, as Adam points out, when using attributes.

It would save all these hours of arguing over _Type vs A_ vs "use more
imagination" .

--
-- Stephe
Reply With Quote
  #63  
Old 08-21-2008, 05:48 AM
Stephen Leake
Guest
 
Default Re: Suffix _T for types found good

Gary Scott <garylscott@sbcglobal.net> writes:

> Stephen Leake wrote:
>> Huh? The problem is that the language rules forbid this:
>>
>> Buffer : Buffer;
>>
>> That is what we would _like_ the language to allow.

>
> what? that looks completely ambiguous in terms of readability. you
> must know some arcane rule to interpret it.


The object is before the colon, the type is after it. Nothing "arcane"
about that. It's just Ada. Different from C, of course.
--
-- Stephe
Reply With Quote
  #64  
Old 08-21-2008, 05:49 AM
Dmitry A. Kazakov
Guest
 
Default Re: Suffix _T for types found good

On Wed, 20 Aug 2008 21:46:48 -0400, Peter C. Chapin wrote:

> I'm not sure allowing such a thing, even if were possible, would be a
> good idea. Types and instances are conceptually quite different and
> allowing them to reuse the same name (in the same scope) sounds
> confusing.


Hmm, exactly because they are so different, it is safe to share names
between them. (I am not arguing in favor of such a step, though)

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
Reply With Quote
  #65  
Old 08-21-2008, 09:53 AM
amado.alves@gmail.com
Guest
 
Default Re: Suffix _T for types found good

> Buffer : Buffer;

This is horrible! Total lack of intuitiveness. You must have imprint
in your brain a totally arbitrary rule. Very hard--maybe only for us
dislexics. Add the little suffix and voila, all is clear in all
languages :-)

Buffer : Buffer_T; -- Ada, Pascal...

Buffer_T Buffer; -- C, C++...
Reply With Quote
  #66  
Old 08-21-2008, 11:30 AM
Gary Scott
Guest
 
Default Re: Suffix _T for types found good

amado.alves@gmail.com wrote:
>>Buffer : Buffer;

>
>
> This is horrible! Total lack of intuitiveness. You must have imprint
> in your brain a totally arbitrary rule. Very hard--maybe only for us
> dislexics. Add the little suffix and voila, all is clear in all
> languages :-)
>
> Buffer : Buffer_T; -- Ada, Pascal...
>
> Buffer_T Buffer; -- C, C++...

Fortram

type(Buffer_T) :: Buffer

--

Gary Scott
mailto:garylscott@sbcglobal dot net

Fortran Library: http://www.fortranlib.com

Support the Original G95 Project: http://www.g95.org
-OR-
Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html

If you want to do the impossible, don't hire an expert because he knows
it can't be done.

-- Henry Ford
Reply With Quote
  #67  
Old 08-22-2008, 12:12 AM
Randy Brukardt
Guest
 
Default Re: Suffix _T for types found good

"Adam Beneschan" <adam@irvine.com> wrote in message
news:2259e1a3-e04c-4662-affb-dae07baa4a43@x16g2000prn.googlegroups.com...
....
> Let me try to make myself clearer: If there were a rule change in Ada
> so that types (or subtypes) could have the same identifiers as other
> entities in the same scope, in many or most cases the compiler could
> unambiguously determine from context whether the identifier refers to
> the type:


Type conversions and array indexing also would be ambiguous:

Some_Array : Some_Array;

.... Some_Array (<expr>) ...

I think that would be much worse than attributes (they're used a lot more,
especially array indexing).

Of course, a language supporting that could have used square brackets for
indexing (like Pascal), and get rid of that problem. But it won't work in
Ada.

Randy.


Reply With Quote
  #68  
Old 08-22-2008, 12:12 AM
Randy Brukardt
Guest
 
Default Re: Suffix _T for types found good

"Adam Beneschan" <adam@irvine.com> wrote in message
news:2259e1a3-e04c-4662-affb-dae07baa4a43@x16g2000prn.googlegroups.com...
....
> Let me try to make myself clearer: If there were a rule change in Ada
> so that types (or subtypes) could have the same identifiers as other
> entities in the same scope, in many or most cases the compiler could
> unambiguously determine from context whether the identifier refers to
> the type:


Type conversions and array indexing also would be ambiguous:

Some_Array : Some_Array;

.... Some_Array (<expr>) ...

I think that would be much worse than attributes (they're used a lot more,
especially array indexing).

Of course, a language supporting that could have used square brackets for
indexing (like Pascal), and get rid of that problem. But it won't work in
Ada.

Randy.


Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 11:55 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.