Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2007-12

Type declaration

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Damien Gerard

Hi !

I would like to know if there are any differences between these two following declarations :

type
    TMyType = smallint;

And

type
   TMyType = type smallint;
Damien Gerard People who used magic without knowing what they were doing usually came to a sticky end. All over the entire room, sometimes. -- (Terry Pratchett, Moving Pictures)

Reply by email

ik
to Damien Gerard

Hi,

Damien Gerard wrote 8 lines
Hi ! I would like to know if there are any differences between these two following declarations : type TMyType = smallint;

This is an "alias" to smallint, giving it a new way reference it.

Show quoted text 5 lines
And type TMyType = type smallint;

This is a new type, that have the range of smallint, but they are not the same. If you will place a TMyType variable inside a smallint paremeter you might have an error or warning of type mismatch.

Show quoted text 10 lines
-- Damien Gerard People who used magic without knowing what they were doing usually came to a sticky end. All over the entire room, sometimes. -- (Terry Pratchett, Moving Pictures)

Ido

Reply by email

Damien Gerard
to ik
ik wrote 24 lines
Hi, On Dec 21, 2007 3:23 PM, Damien Gerard wrote: > > Hi ! > > I would like to know if there are any differences between these two > following declarations : > > type > TMyType = smallint; This is an "alias" to smallint, giving it a new way reference it. > > And > > type > TMyType = type smallint; This is a new type, that have the range of smallint, but they are not the same. If you will place a TMyType variable inside a smallint paremeter you might have an error or warning of type mismatch.

I like it :)
Thanks !

Damien Gerard People who used magic without knowing what they were doing usually came to a sticky end. All over the entire room, sometimes. -- (Terry Pratchett, Moving Pictures)

Reply by email