cqcallaw / newt Goto Github PK
View Code? Open in Web Editor NEWThe newt programming language
License: GNU General Public License v3.0
The newt programming language
License: GNU General Public License v3.0
It is not currently possible to invoke a function from within the function's body
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)
This seems like a hard requirement for any sort of library support (e.g. string processing or math functions)
It would be useful to perform semantic analysis of a program without actually executing it.
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.
Making simple data structures like linked lists depend on this
Allow variables, parameters, and return values to be of multiple, otherwise unrelated types, e.g. (point | error)
It would be useful to have a list of known parse errors instead of just the first error.
Related resource: https://www.gnu.org/software/bison/manual/html_node/Error-Recovery.html
This is particularly bad if the return type is undefined.
I have mixed feelings about this, as the language was originally intended for scripting, and namespaces feel a bit enterprise-y.
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)
An insufficiently deep analysis masked this problem previously
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.
AssignmentStatement::preprocess may be duplicating work with the Variable::Validate method. Investigate and dedupe as needed
It seems useful to flag functions without side effects as "pure"
This is not currently possible to test fully because in the current implementation array index assignment makes every array operation a copy operation. Consequently, this task is related to #15
Possibly via http://site.icu-project.org/
A lot can be done with refcounting, but not everything
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.
newt supports print statements that output to stdout, but I/O is otherwise unsupported.
Byte-level manipulation is likely a prerequisite for this
E.g. "readonly" or "mutable"
Sum types are not yet nestable, but this feature is desirable
The initializer expression, type, and name properties appear to be shared.
The use of using namespace
is commonly understood to be bad practice.
Allow the value of an array, set, map, etc. to be defined literally in the source code
A backslash seems like an appropriate token for this
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.
Some experimentation with Travis CI has been done, but it is not currently active
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"
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.
See mt5108 and mt5109
This change would probably necessitate a mutable
keyword
Some good ideas here: http://danluu.com/testing/
newt is not intended to be a systems language, neither is high performance a primary goal. Avoiding overflow and rounding issues may be well worth the decreased performance in this context
We may not be able to do much, but should do as much as we can.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.