Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

defstructs and packages

Name: Anonymous 2011-07-27 16:43

Why CL includes two non-orthogonal concepts for code organization? Why to define an IMAGE package I have to separately declare (defstruct image-state ...)?

Can we replace defstructs with packages in future Lisps?

Name: Anonymous 2011-07-27 18:03

defstruct is pretty old and you should use CLOS instead of it, unless you need performance(or just have no need for CLOS' full power), in which case you can either use structures or classes stored as structures (different metaclass, slightly unportable, but I haven't encountered an implementation where it doesn't work).

Packages are just slightly enhanced collections of symbols, and I don't see why would you think structures and packages are related except in the ways symbols are related with the rest of the language.

Why to define an IMAGE package I have to separately declare (defstruct image-state ...)?
I don't understand this part of your statement at all. To define an image package you use (defpackage image ...). If you want to make your structures/classes visible in another package, you can always import the symbols.

>>1,4
Are we both talking about the same concept, because I don't think we are. Modifying a structure at runtime may require recompiling certain portions of your program, but I don't ``bounce'' (half-restart) my lisp that often, you can change packages or even structures at runtime, but some details regarding structures are not as portable across implementation (hence why CLOS should be used if you want such gurantees).

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List