develooper Front page | perl.perl5.porters | Postings from July 2020

Re: Types in Cor (and Perl)

Thread Previous | Thread Next
From:
=?UTF-8?Q?Branislav_Zahradn=C3=ADk?=
Date:
July 13, 2020 14:29
Subject:
Re: Types in Cor (and Perl)
Message ID:
CAB=rbOkbTAQEzzbL8aGhMghB0EMDne9TY+Y9Yv+hqGL20PHkZA@mail.gmail.com
I see types and constraints are fundamentally one and the same thing.
>
> A type is fundamentally just a set of values, such as the set of integer
> values
> or the set of array values or the set of all values.
>
>
example (I found such code in java codebase):
class Limit { ... enforces min/max 0/1000 }

class Foo extends Limit { Foo (int i) { super (i/3) } }

Type check: Foo is a Limit
Constraint check: Foo is not a Limit (only 1/3)



>
> Primitives and strong types are very frequently used.
>
> The whole concept of primitive types is mostly arbitrary.  For example, is
> a
> character string a primitive type or is it an array of characters?
>
>
Strong types are not tied to primitive types, they are very separate
> concepts.
>
>
Fair point. So let me define what I understand as a primitive type:
- primitive type defines a storage class of data (I/O serialization)
- non-primitive type defines meaning of data.

Under strong types concept I do understand the strong definition of meaning
of data.

So commenting Ovid's Dollar/Euro example:
- Num is primitive type
- Dollar/Euro are non-primitive types

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About