{"size": 1456, "ext": "scrbl", "max_stars_repo_path": "pkgs/racket-doc/scribblings/reference/prop-port.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/scribblings/reference/prop-port.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/scribblings/reference/prop-port.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": 40.4444444444, "max_line_length": 77, "alphanum_fraction": 0.7616758242}
#lang scribble/doc
@(require "mz.rkt")

@title[#:tag "portstructs"]{Structures as Ports}

@defthing[prop:input-port struct-type-property?]
@defthing[prop:output-port struct-type-property?]

The @racket[prop:input-port] and @racket[prop:output-port] structure type
properties identify structure types whose instances can serve as input
and output ports, respectively.

Each property value can be either of the following:

@itemize[
 
 @item{An input port (for @racket[prop:input-port]) or output port
  (for @racket[prop:output-port]): In this case, using the structure
  as port is equivalent to using the given input or output port.}

 @item{An exact, non-negative integer between @racket[0] (inclusive) and
  the number of non-automatic fields in the structure type (exclusive, not
  counting supertype fields): The integer identifies a field in
  the structure, and the field must be designated as immutable. If the
  field contains an input port (for @racket[prop:input-port]) or
  output port (for @racket[prop:output-port]), the port is used.
  Otherwise, an empty string input port is used for @racket[prop:input-port],
  and a port that discards all data is used for @racket[prop:output-port].}

]

Some procedures, such as @racket[file-position], work on both input
and output ports. When given an instance of a structure type with both
the @racket[prop:input-port] and @racket[prop:output-port] properties,
the instance is used as an input port.
