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

Proposed function: (using ...) #4

Open
jarcane opened this issue Nov 20, 2014 · 1 comment
Open

Proposed function: (using ...) #4

jarcane opened this issue Nov 20, 2014 · 1 comment

Comments

@jarcane
Copy link
Owner

jarcane commented Nov 20, 2014

At the present moment, Heresy lacks I/O routines beyond the simple console IO provided by print and input.

However, we have in our hands already the tools then for some basic file I/O: Racket's print and read routines generally default to a port, and as well there is syntax provided to parameterize just which port those routines point to.

BASIC as well already supplies a very similar approach to I/O: The USING keyword. This is defined in the ECMA standard, as well as many MS-derived BASICs, used to point the output of PRINT to a specific port number (generally mapped to disk and printers and such).

I propose borrowing this as a parameterized block, with syntax to indicate what target or source is to be operated on. Initially, I think file I/O is probably the most useful here, and suggest something like the following:

(using file *filename* as ['write/read]
  ...)

This does beg the question however of whether this violates the functional principle, but remember Rule #3, Heresy is not Haskell. As well, I think limiting this behavior to within explicit 'impure' code-blocks like (using) helps preserve the feel as well, enforcing a certain attention to what is happening whenever such IO is undertaken.

Then again, I may just be mad.

@jarcane
Copy link
Owner Author

jarcane commented Dec 23, 2014

Implemented for files now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant