Skip to content

Describing Basic Types

Sean DeNigris edited this page Nov 24, 2017 · 1 revision

When you have e.g. a MAToManyRelationDescription that allows instances of classes like ZnUrl, when you try to "Add" one, you get a blank Magritte editor. Here is one technique to meta-describe such a basic class. Note that it requires mutating an existing instance, so would not be appropriate for an immutable type like String.

ZnUrl >> #descriptionString
	<magritteDescription>
	^ MAStringDescription new
			accessor: (MASelectorAccessor read: #asString write: #parseFrom:);
			yourself

One might wonder: "Is MAStringDescription really the most appropriate Description class?" It does seem a little hacky, but MAElementDescription failed because it tries to use Object's default #readFrom:, which apparently tries to compile the string as code! A workaround to that could be to specify a #kind: String, but would that be any better than the current solution? Maybe the most intention revealing would be a new Description class, like "MAMutableObjectDescription", but we'll wait and see how it goes.

Clone this wiki locally