Stabel

Ticket Change Details
Login
Overview

Artifact ID: 4a57ca5977728ec45a167f06a78297c9a24f1a11186beaf19fe600d726314281
Ticket: 55a5b57c3ba6bc14344d83baf320576cda41859b
0.3.0: Integer improvements
User & Date: robin.hansen on 2021-08-10 09:26:00
Changes

  1. icomment:
    <h1>Integer improvements</h1>
    
    The current support for integers in Stabel is quite limited. You can perform basic operations like equality, addition, subtraction, multiplication and division, as well as two-three additional operations defined in the standard library.
    
    Note that there is no comparison functions, no bitwise functions or more advanced math functions.
    
    In addition, the only form of integer literals currently supported is positive integers in base-10 format.
    
    If Stabel want to be a general purpose language, the support for integers has to be improved.
    
    <h2>Goals</h2>
    
      *  Support most, if not all, of the basic integer operations currently available in <a href="https://www.w3.org/TR/wasm-core-1/#numeric-instructions%E2%91%A0" title="Web Assembly Numeric Instructions spec">web assembly</a>
      *  Support negative integers in base 10 format
      *  Add support for hex literals
      *  Add support for binary literals
      *  Let integers use underscore as a separator, to make big numbers easier to read
    
    <h2>Non-goals</h2>
    
      *  Add support for variable sized integers (8-bit, 16-bit, 64-bit) at this time. This is planned for a future release
      *  Unsigned integers. Not sure if they're really needed? A lot of languages does fine without them (like Java)
      *  Octal literals. I've personally never seen these being used. Would love to be told of a valid use case
      *  Floats. This will be a looked at in a future release
    
    <h2>Description</h2>
    
    When it comes to improving literal formats, we'll stick to what's known to work well in other languages.
    
      *  0x marks the beginning of a hex literal: <code>0xFFFF</code>
      *  0b marks the beginning of a binary literal: <code>0b0101</code>
      *  Underscores can be used to improve readability:  <code>1_000</code>, <code>0b01_00</code>, <code>0xFA_01</code>
    
    For negative integers in base 10, I propose the negative sign being postfix like so: 100-
    
    This is different from most other languages, but in most other languages the minus symbol isn't a valid function name, which it is in Stabel. By having the minus sign as postfix we avoid complicated rules in the parser for what constitutes a number and what constitutes a function.
    
    When it comes to supporting additional operations, I propose that extra functionality is moved to <i>math</i> and <i>bitwise</i> modules depending on what categories those fit in. This requires some refactoring in the compiler around handling builtins, but is something that would likely have to be done anyway for supporting strings and arrays.
    
    I also propose that in addition to supporting all intrinsic integer operations of the wasm spec, that we try to support all math operations available in the Elm core library for integers. If nothing else, we should at least be as good as Elm after the next major release.
    
  2. login: "robin.hansen"
  3. mimetype: "text/x-fossil-wiki"
  4. severity changed to: "Important"
  5. status changed to: "Open"
  6. subsystem changed to: "Compiler"
  7. title changed to: "0.3.0: Integer improvements"
  8. type changed to: "Language_Proposal"