racket - What is the difference between a transparent and a prefab struct? -


as title implies, don't understand difference between using #:transparent , using #:prefab when defining struct. reference mentions prefab involves sort of global sharing.

what difference between them? in situation should use 1 on other?

to make structure type transparent, use #:transparent keyword after field-name sequence:

(struct posn (x y)         #:transparent)  > (posn 1 2) (posn 1 2) 

an instance of transparent structure type prints call constructor, shows structures field values. transparent structure type allows reflective operations, such struct? , struct-info, used on instances.

although transparent structure type prints in way shows content, printed form of structure cannot used in expression structure back, unlike printed form of number, string, symbol, or list.

a prefab (“previously fabricated”) structure type built-in type known racket printer , expression reader. infinitely many such types exist, , indexed name, field count, supertype, , other such details. printed form of prefab structure similar vector, starts #s instead of #, , first element in printed form prefab structure type’s name.

lastly, think may need using #:transparent of time on #:prefab ,based on experience use #:transparent.


Comments

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -