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

R7RS Support #24

Open
justinethier opened this issue Apr 18, 2011 · 12 comments
Open

R7RS Support #24

justinethier opened this issue Apr 18, 2011 · 12 comments

Comments

@justinethier
Copy link
Owner Author

According to the r7rs specification, the full list of changes up to this point is as follows. I will cross these out as support is added to husk:

  • Libraries have been added as a new program structure
    to improve encapsulation and sharing of code. Some
    existing and new identifiers have been factored out
    into separate libraries. Libraries can be imported into
    other libraries or main programs, with controlled exposure
    and renaming of identifiers. The contents of a
    library can be made conditional on the features of the
    implementation on which it is to be used. There is an
    R5RS compatibility library.
  • The expressions types include, include-ci, and
    cond-expand have been added to the base library;
    they have the same semantics as the corresponding
    library declarations.
  • Exceptions can now be signaled explicitly with raise,
    raise-continuable or error, and can be handled
    with with-exception-handler and the guard syntax.
    Any object can specify an error condition; the
    implementation-defined conditions signaled by error
    have a predicate to detect them and accessor functions
    to retrieve the arguments passed to error. Conditions
    signaled by read and by file-related procedures also
    have predicates to detect them.
  • New disjoint types supporting access to multiple fields
    can be generated with the define-record-type of
    SRFI 9 [19]
  • Parameter objects can be created with
    make-parameter, and dynamically rebound with
    parameterize.
    The procedures current-input-port
    and current-output-port are now parameter
    objects, as is the newly introduced
    current-error-port.
  • Bytevectors, vectors of exact integers in the range
    from 0 to 255 inclusive, have been added as a new
    disjoint type. A subset of the vector procedures is
    provided. Bytevectors can be converted to and from
    strings in accordance with the UTF-8 character encoding.
    Bytevectors have a datum representation and
    evaluate to themselves.
  • Vector constants evaluate to themselves.
  • The procedure read-line is provided to make line-oriented textual input simpler.
  • The procedure flush-output-port is provided to allow minimal control of output port bu�ffering.
  • Ports can now be designated as textual or binary ports,
    with new procedures for reading and writing binary
    data. The new predicates input-port-open? and
    output-port-open? return whether a port is open or
    closed. The new procedure close-port now closes a
    port; if the port has both input and output sides, both
    are closed.
  • String ports have been added as a way to read and
    write characters to and from strings, and bytevector
    ports to read and write bytes to and from bytevectors.
  • There are now I/O procedures specific to strings and
    bytevectors.
  • The R6RS procedure eof-object has been added. Eof-objects are now required to be a disjoint type.
  • Syntax definitions are now allowed wherever variable
    definitions are.
  • The syntax-rules construct now allows the ellipsis
    symbol to be specified explicitly instead of the default
    ..., and allows tail patterns to follow an ellipsis pattern
    .
  • The syntax-error syntax has been added as a way to signal immediate and more informative errors when a macro is expanded.
  • The letrec* binding construct has been added, and internal define is specified in terms of it.
  • Support for capturing multiple values has been
    enhanced with define-values, let-values, and
    let*-values
    . Standard expression types which contain
    a sequence of expressions now permit passing zero
    or more than one value to the continuations of all non-
    final expressions of the sequence.
  • The case conditional now supports => syntax analogous to cond not only in regular clauses but in the else clause as well.
  • To support dispatching on the number of arguments
    passed to a procedure, case-lambda has been added
    in its own library.
  • The convenience conditionals when and unless have been added.
  • The behavior of eqv? on inexact numbers now conforms
    to the R6RS definition.
  • When applied to procedures, eq? and eqv? are permitted to return diff�erent answers.
  • The R6RS procedures boolean=? and symbol=? have been added.
  • The log procedure now accepts a second argument specifying the logarithm base.
  • The procedures map and for-each are now required to terminate on the shortest argument list.
  • The procedures member and assoc now take an optional
    third argument specifying the equality predicate
    to be used.
  • The numeric procedures finite?, infinite?, nan?, exact-integer?, square, and exact-integer-sqrt have been added.
  • Positive infinity, negative infinity, NaN, and negative
    inexact zero have been added to the numeric
    tower as inexact values with the written representations
    +inf.0, -inf.0, +nan.0, and -0.0 respectively.
    Support for them is not required. The representation
    -nan.0 is synonymous with +nan.0.
  • The - and / procedures and the character and string
    comparison predicates are now required to support
    more than two arguments.
  • The forms #true and #false are now supported as well as #t and #f.
  • The procedures make-list, list-copy, list-set!,
    string-map, string-for-each, string->vector,
    vector-append, vector-copy, vector-map,
    vector-for-each, vector->string, vector-copy!,
    and string-copy! have been added to round out the
    sequence operations.
  • Some string and vector procedures support processing of part of a string or vector using optional start and end arguments.
  • Implementations may provide any subset of the full Unicode repertoire that includes ASCII, but implementations must support any such subset in a way consistent with Unicode. Various character and string procedures have been extended accordingly, and caseconversion procedures added for strings. String comparison is no longer required to be consistent with character comparison, which is based solely on Unicode scalar values. The new digit-value procedure has been added to obtain the numerical value of a numeric character.
  • Strings and symbols now allow mnemonic and numeric escape sequences, and the list of named characters has been extended.
  • The procedures file-exists? and delete-file are available in the (scheme file) library.
  • An interface to the system environment, command
    line, and process exit status is available in the (scheme
    process-context) library.
  • Procedures for accessing time-related values are available in the (scheme time) library.
  • A less irregular set of integer division operators is provided
    with new and clearer names.
  • The load procedure now accepts a second argument specifying the environment to load into.
  • The call-with-current-continuation procedure now has the synonym call/cc.
  • The semantics of read-eval-print loops are now partly prescribed, requiring the redefinition of procedures, but not syntax keywords, to have retroactive eff�ect.
  • The formal semantics now handles dynamic-wind.
  • Transcript-on and transcript-off have been removed.

The following are unlikely to be implemented:

  • Some list procedures are now defined on circular lists.
  • The write procedure now generates datum labels
    when applied to circular objects. The new procedure
    write-simple never generates labels; write-shared
    generates labels for all shared and circular structure.
    The display procedure must not loop on circular objects.
  • Data prefixed with datum labels #= can be referenced
    with ##, allowing for reading and writing of
    data with shared structure.
  • The syntax-rules construct now allows template escapes with an ellipsis-prefixed
    list.
  • There are now two additional comment syntaxes: #;
    to skip the next datum, and #| ... |# for nestable
    block comments
    .
  • Support for promises has been enhanced based on
    SRFI 45 (cannot be implemented directly per spec due to Husk's restrictions of set-car! and set-cdr!).
  • Case folding, EG: include-ci

@joshtriplett
Copy link
Contributor

Of all of those, I'd really love to see the R7RS module system. That would help greatly with code structuring when using scheme as an extension language for a Haskell program.

@justinethier
Copy link
Owner Author

Thanks for the feedback. I had been holding off on this because WG1 has made changes to the module section since their first draft. But modules are the most important addition in R7RS and even a minimal, partial implementation would probably be useful in husk...

@joshtriplett
Copy link
Contributor

If you think that the module API will change incompatibly before the final release of R7RS, then by all means feel free to wait until it becomes more stable. No rush.

@justinethier
Copy link
Owner Author

The plan is for the next release of husk to start having limited support for R7RS-style modules.

Going forward, R7RS items may be added as extensions if they are new "features" that do not break existing R5RS functionality. Any breaking changes will have to be included in a future "R7RS" mode, probably via command line arguments used to load a separate environment.

@justinethier
Copy link
Owner Author

Notes on how Gauche is implementing R7RS:

http://blog.practical-scheme.net/gauche/20130522-r7rs

@jrmithdobbs
Copy link

call-with-port would be a great addition.

justinethier added a commit that referenced this issue May 5, 2014
@justinethier
Copy link
Owner Author

@jrmithdobbs - Thanks for the suggestion, this is a simple function to provide...

@jrmithdobbs
Copy link

Awesome. Also wondering why the srfi45 inspired changes aren't planned? It seems to me delay-force (srfi45's "lazy") should be fairly straightforward, easier, even, than most other implementations given the host metalanguage. :)

@justinethier
Copy link
Owner Author

@jrmithdobbs - Unfortunately, the way Husk is written makes it more difficult to implement SRFI 45 from spec. The problem is that set-car! and set-cdr! operate on Haskell lists instead of pointers. So you can't do some of the usual tricks with them that other Schemes support. Sorry :(

Nothing against SRFI 45. I would take a pull request for it, just have no plans to implement it anytime soon.

@jrmithdobbs
Copy link

Ah! Makes sense. Figured there was a reason. Why I asked. ;)

@justinethier
Copy link
Owner Author

Sure, no problem. I should be more clear about why it is on that list.

In any case this is an unfortunate restriction but there are ways to work around it.

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

No branches or pull requests

3 participants