Coder Social home page Coder Social logo

cqcallaw / newt Goto Github PK

View Code? Open in Web Editor NEW
11.0 11.0 2.0 3.1 MB

The newt programming language

License: GNU General Public License v3.0

Makefile 4.38% C++ 90.53% C 0.34% Lex 1.36% Yacc 3.40%
functional-programming programming-language scripting-language ux

newt's People

Contributors

cqcallaw avatar gitter-badger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

newt's Issues

Function overloading

Note: we must be sure the side-by-side declarations f:= (a:int) -> int and f:= (a:int=2) -> int are handled correctly (they have the same signature, but one has a default value)

Implicit string conversion of structs

Being able to write print my_struct_instance and get a meaningful output is useful. It is also useful to concatenate a struct's string representation with another string. Invoking an optional to_string struct method (see #7) seems reasonable, with fallback to a default string representation.

to_string signature should simply be (compound_type) -> string

The circumstances in which stringification can be inferred are limited: adding an integer value to a struct instance should still be a type mismatch error.

Sum Types

Allow variables, parameters, and return values to be of multiple, otherwise unrelated types, e.g. (point | error)

struct methods

Having a type

struct point {
    x:int
    y:int
}

and a function

translate:= (p:point, x_offset:int, y_offset:int) -> point {
    return p with { x = p.x + x_offset, y = p.y + y_offset }
}

It would be convenient and aligned with the language goal of succinctness to be able to write

p:= @Point with { x = 2, y = 3 }
p2:= p.translate(4, 5)

Refactor array variable parsing

Array variables were implemented before the ":=" declaration syntax, and some inelegant code was written to work around parsing limitations. It would be cleaner for an array variable to be an operator on a variable reference instead of an identifier.

Pure functions

It seems useful to flag functions without side effects as "pure"

Explore copy-on-write data structures

For simplicity, newt currently inserts a new symbol into the symbol table when a new value is assigned to a variable. This is true for arrays as well, which makes array operations very expensive; updating a single element of the array triggers a copy of the entire array.

Copy-on-write data structures may be an interesting solution to this problem, and many others.

I/O

newt supports print statements that output to stdout, but I/O is otherwise unsupported.

Byte-level manipulation is likely a prerequisite for this

Nested sum types

Sum types are not yet nestable, but this feature is desirable

Collection literals

Allow the value of an array, set, map, etc. to be defined literally in the source code

Enable version specification

Specifying language version compatibility at the top of the script seems like a robust way to avoid grammar and semantic mismatches as the language evolves.

Continous Integration

Some experimentation with Travis CI has been done, but it is not currently active

Type-distinguished Product types

A product type is a type that contains a value for all of its member types. That is, a product type int & double would contain both an int and a double value. This feature is a requirement for the current vision for function overloading (#6).

Extracting a member value of a product type can be done implicitly:

a:= 35 & "howdy"
s:string = a #s == "howdy"

Modifying a member value of a product type can also be implicit, though this doesn't feel great:

a:= 35 & "howdy"
a = 42 #updates the integer value; a == 42 & "howdy"

Inferred return types

For one-liner anonymous functions, inferring the return type is handy.

Care should be taken to engineer this so it's not encouraged for larger functions where the return type is important for verifying the semantic correctness of the function.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.