Skip to content
This repository has been archived by the owner on May 11, 2019. It is now read-only.

RFC: Primitive Types and Type Qualifiers #12

Closed
Qix- opened this issue May 31, 2016 · 1 comment
Closed

RFC: Primitive Types and Type Qualifiers #12

Qix- opened this issue May 31, 2016 · 1 comment

Comments

@Qix-
Copy link
Owner

Qix- commented May 31, 2016

Arua's primitive types consist of integers (unsigned/signed), floating point numbers, and arrays of those types. To be clear, arrays of types (including arrays of primitives) are their own individual types and are not directly coercible to their primitive counterparts.

Type Qualifiers

All declarations (foo Type) are considered immutable without the mutable type qualifier (foo !Type). As well, all declarations are considered mandatory (cannot be nil) unless they have the optional type qualifier (foo Type?). These qualifiers can be combined (foo !Type?). Type qualifiers do not create or affect any type (they describe individual usages of existing types within a statement, rather than define the type itself).

Implicit Conversions

Implicit Conversions are intuitive and simple in Arua. For a unit with a type Child that is a sub-type of Base (e.g. via a typedef):

row = column Base Child !Base !Child Base? Child? !Base? !Child? nil
Base ✓* ✓* ✓* ✓*
Child ✓* ✓*
!Base
!Child
Base? ✓* ✓* ✓* ✓* ✓* ✓* ✓* ✓* ✓*
Child? ✓* ✓* ✓* ✓* ✓*
!Base?
!Child?

* Only if it's the initial assignment

Optional Qualifiers

Optional qualifiers force a check of nil for all types before they can be referenced.

foo Type? = getFoo()
foo.someMethod() # compilation error

# ---

foo Type? = getFoo()
if foo != nil
    foo.someMethod() # compiles OK

This check honors visibility (#19). Calls into functions check that operate on optional types must be in code paths that have already checked for nil. Unit-public functions always assume such checks have not been made.

pub fn publicFunction(foo Type?)
    privateFunction(foo) # error - privateFunction() argument `bar` is not optional protected

fn privateFunction(bar Type?)
    bar.someMethod() # doesn't check for `nil`
pub fn publicFunction(foo Type?)
    if foo != nil
        privateFunction(foo) # compiles okay

fn privateFunction(bar Type?)
    bar.someMethod() # doesn't check for `nil`

Signed-ness

All signed types (i32, i16, i8, iXX) are Two's Complement representations.

Floating Point

All floating point types (f32, f64, fXX) are IEEE 754 compliant floating point numbers.

@Qix- Qix- changed the title RFC: Primitives RFC: Primitives types and Type Qualifiers Jun 2, 2016
@Qix- Qix- changed the title RFC: Primitives types and Type Qualifiers RFC: Primitive Types and Type Qualifiers Jan 27, 2017
@Qix-
Copy link
Owner Author

Qix- commented Feb 5, 2017

Rejecting this as the type system has been revised a bit. The pieces are the same, but the ways they are semantically represented/used are now different.

For example, mutability is being broadened to mean Does not incur side effects - not just that it doesn't change the object's state. This means no I/O, etc. Routines being evaluated for side effects is now a language feature, as will be described in future RFCs.

@Qix- Qix- closed this as completed Feb 5, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant