How do I get the type of a value in Scheme?

前端 未结 4 1651
情话喂你
情话喂你 2021-01-01 13:58

I want a function that gets the type of a value at runtime. Example use:

(get-type a)

where a has been defined t

4条回答
  •  情深已故
    2021-01-01 14:46

    All of the answers here are helpful, but I think that people have neglected to explain why this might be hard; the Scheme standard doesn't include a static type system, so values can't be said to have just one "type". Things get interesting in and around subtypes (e.g. number vs floating-point-number) and union types (what type do you give to a function that returns either a number or a string?).

    If you describe your desired use a bit more, you might discover that there are more specific answers that will help you more.

提交回复
热议问题