{"size": 2190, "ext": "scrbl", "max_stars_repo_path": "pkgs/racket-doc/syntax/scribblings/define.scrbl", "max_stars_repo_name": "lkh01/racket", "max_stars_repo_stars_event_min_datetime": "2018-07-29T04:13:52.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-14T16:11:17.000Z", "max_issues_repo_path": "pkgs/racket-doc/syntax/scribblings/define.scrbl", "max_issues_repo_name": "lkh01/racket", "max_issues_repo_issues_event_min_datetime": "2017-08-25T20:26:37.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T17:48:40.000Z", "max_forks_repo_path": "pkgs/racket-doc/syntax/scribblings/define.scrbl", "max_forks_repo_name": "lkh01/racket", "max_forks_repo_forks_event_min_datetime": "2016-04-25T11:47:57.000Z", "max_forks_repo_forks_event_max_datetime": "2017-05-09T14:52:48.000Z"}
{"max_stars_count": 10, "max_issues_count": 15, "max_forks_count": 3, "avg_line_length": 41.320754717, "max_line_length": 77, "alphanum_fraction": 0.6579908676}
#lang scribble/doc
@(require "common.rkt" (for-label syntax/define))


@title[#:tag "define"]{Parsing @racket[define]-like Forms}

@defmodule[syntax/define]

@defproc[(normalize-definition [defn-stx syntax?]
                               [lambda-id-stx identifier?]

                               [check-context? boolean? #t]
                               [opt+kws? boolean? #f])
         (values identifier? syntax?)]{

Takes a definition form whose shape is like @racket[define] (though
possibly with a different name) and returns two values: the defined
identifier and the right-hand side expression.

To generate the right-hand side, this function may need to insert uses
of @racket[lambda]. The @racket[lambda-id-stx] argument provides a
suitable @racket[lambda] identifier.

If the definition is ill-formed, a syntax error is raised. If
@racket[check-context?] is true, then a syntax error is raised if
@racket[(syntax-local-context)] indicates that the current context is
an expression context. The default value of @racket[check-context?] is
@racket[#t].

If @racket[opt+kws?] is @racket[#t], then arguments of the form
@racket[[id expr]], @racket[keyword id], and @racket[keyword [id
expr]] are allowed, and they are preserved in the expansion.}

@defproc[(normalize-definition/mk-rhs [defn-stx syntax?]
                                      [lambda-id-stx identifier?]
                                      [check-context? boolean?]
                                      [opt+kws? boolean?]
                                      [err-no-body? boolean?])
         (values identifier? (-> syntax? syntax?) syntax?)]{

  The helper for @racket[normalize-definition] that produces three values:
  the defined identifier, a function that takes the syntax of the body
  and produces syntax that has the expected binding structure, and
  finally the right-hand side expression that @racket[normalize-definition]
  gives to the previous function.

  If @racket[err-no-body?] is true, then there must be a right-hand side
  expression or else it is a syntax error. The @racket[err-no-body?] argument
  is true for uses of @racket[normalize-definition].

  @history[#:added "6.1.1.8"]
}
