edoput
edoput

Reputation: 1212

Scheme names with * as suffix

There are some forms in the tradition of Scheme that are named the same as more primitive forms but with a * appended as a suffix.

Some examples

let* define*

Now for these derived forms the explanation is that you get visibility of your previous bindings in the later bindings kind of a letrec style but creating one id at a time instead of all at once (?).

Now this pattern extends thought to other forms and some packages have custom macros with the * symbol as a suffix (define-ratbag*). Is this some implicit convention of the Scheme tribe, is this documented somewhere?

Upvotes: 2

Views: 121

Answers (1)

Ryan Culpepper
Ryan Culpepper

Reputation: 10643

There are several things that a * suffix might mean:

  • sequential scoping like let*, as opposed to independent scoping like let. Examples: with-syntax* is like with-syntax, but each right-hand side is in the scope of previous clauses.
  • sequential effect as opposed to independent effect. Examples: parameterize* is like parameterize, but each parameter's new value is evaluated with the previous parameters updated to their new values; with-handlers* is like with-handlers, but each exception handler is called in a context with the previous exception handlers installed.
  • like the other thing, but multiple times. Examples: remove* is like remove, but removes all occurrences of the given element; regexp-match* is like regexp-match, but finds all matches.
  • like the other thing, but the final argument acts like a rest-argument. Examples append*, list*: (append* vss) is equivalent to (apply append vss).
  • like the other thing, but accepts multiple arguments. Examples: hash-set* is like hash-set, but accepts multiple key-value pairs.
  • like the other thing, but just a bit different. Examples: write-bytes-avail* is like write-bytes-avail, except it never blocks; date* is like date except it adds nanosecond and time-zone-name fields; call-with-input-file* is like call-with-input-file except closes the input port on escapes. In this usage, you can read * as Scheme/Racket's version of a prime suffix.

Upvotes: 9

Related Questions