Skip to content
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

wdte: allow impure functions #158

Open
DeedleFake opened this issue Nov 11, 2018 · 0 comments
Open

wdte: allow impure functions #158

DeedleFake opened this issue Nov 11, 2018 · 0 comments

Comments

@DeedleFake
Copy link
Owner

DeedleFake commented Nov 11, 2018

Due to #157, it is now rather difficult, if not impossible, to write a function that doesn't expect to return the same result every time for the same arguments. For example, let's assume there's some function that reads a line from a Reader, such as readLine. Before #157,

let x => readLine io.stdin;
io.stdout
-> io.writeln x
-> io.writeln x
;

would have read and then written two successive lines from and to stdin and stdout, respectively. Because of #157, however, only one line is read. However, what if the old behavior is the intended behavior? It's now not possible to create a function that does different things each time it's called.

The solution I'm leaning towards right now is to add a new function modifier, impure, which specifies that the results of the function should not be cached. It's essentially the opposite of memo. If the above had had the line let impure x => readLine io.stdin; instead, then it would have used the old behavior.

An alternative would be to take copy Haskell and make I/O a unique type of operation, but I'd rather leave things up to the user as much as possible. As such, another function modifier that might be useful is something like immediate or imperative, which would cause an expression to be evaluated at the time that it's placed into the scope, rather than when it's gotten later. This could be useful to make sure that things are evaluated in the intended order.

@DeedleFake DeedleFake self-assigned this Nov 11, 2018
@DeedleFake DeedleFake added this to Todo in Initial Implementation via automation Nov 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

1 participant