-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prelude split into multiple files #133
Conversation
Now the Prelude is split into several files. The two most notable files are `Base/Types` with some standard types and `Base/Operators` with some standard operators. Each of other files contains only methods that should be visible without importing anything. There is no `Base/List` file with standard methods on list. The user must import `List` module by himself. Other minor changes are the following: - Added LICENSE header in each library file - Added comparison operators for Bool type - Removed `makeString` method (function?), as it seemed broken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote some changes and suggestions. One things that struck out are, it's really hard to test functions that use `re implicit.
pub method fn (>>) = shiftr | ||
pub method fn (>>>) = ashiftr | ||
|
||
pub method fn (:=) = set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we would want some unary operator for get? Ocaml's (! .) works fine for me but maybe there is a better one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about it. The nice thing about unary operator (! .)
in OCaml is that it is a) short, and b) it has very high precedence (higher than application). I think a method get
also has both of these advantages. Moreover, I see the two arguments against OCaml-like (! .)
:
- it misleadingly resembles negation in some languages (like C)
- it introduces some problems with operator lexing:
!
and!=
starts with the same character, but have very different precedence (see PR Fix!=
operator in lexer #125).
pub let charListToStr = (extern dbl_chrListToStr : List Char -> String) | ||
|
||
pub method code {self : Char} = | ||
extern dbl_chrCode : Char -> Int | ||
|
||
pub let chr {`re : {type X} -> Unit ->[|_] X} (n : Int) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as a user i would expect to see function like this in Char module, and also those modules are a good place to add any functions (not only methods) attached to these types, but not necessarily being dependent on any value of this type. Such as chr
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. However, I'm against moving it into /Base/Char/
as the main purpose of this module is to contain methods that might be used without importing Char
explicitly. We should create a separate module Char
for that. I thing it can be done as a separate task.
pub method le = (extern dbl_leStr : String -> String -> Bool) self | ||
|
||
pub method length = (extern dbl_strLen : String -> Int) self | ||
pub method get {`re : {type X} -> Unit ->[|_] X, self : String} (n : Int) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are thinking of adding arrays, and there accessor to specyfic element of array is method at
, maybe its a good idea to keep consistency and also name this method at
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In arrays (#126) the at
accessor is only for writing. Just to be able to write code like arr.at 42 := 13
. For reading we have get
. I don't see how to define a single accessor for both reading and writing.
import /Base/Bool | ||
import /Base/Int | ||
import /Base/Char | ||
import /Base/String |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we will add more functionality to String module, and then i would expect to access that functionality with import String
instead of having to write import /Base/String
in repl.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I answered to chr
issue, the purpose of /Base/String
is to have only some basic methods there. For other functions I would prefer to have a separate String
module.
Yes, I also noticed that. There is a separate issue on that (#131). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't see any more issues
Now the Prelude is split into several files. The two most notable files are
Base/Types
with some standard types andBase/Operators
with some standard operators. Each of other files contains only methods that should be visible without importing anything. There is noBase/List
file with standard methods on list. The user must importList
module by himself.Other minor changes are the following:
makeString
method (function?), as it seemed broken.Fixes #129 and #132