[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: What is an object?
> BTW. - this is a slightly related question, but independent, and
> it isn't even a question...
>
> The compiled, binary code of MrEd contains several dozens, perhaps
> more than a hundred occurrences of the string "ivar/proc". I wonder
> why...
OK, I can answer your non-question.
(ivar/proc object symbol) extracts the public member in the object named
by the symbol.
'send' is just a macro that eventually expands to a use of ivar/proc.
Look up ivar/proc in Help Desk.
Sometimes using ivar/proc directly is useful, as in the following
example from the MysterX Dynamic HTML test suite:
---
(define filter-spec
'(glow (strength 99) (enabled #t) (color "#ff00ff")))
(apply (ivar/proc txt 'set-filter!) filter-spec)
(let ([result (send txt filter)])
(if (equal? result filter-spec)
(printf "Checking filter~n")
(error (format "filter test: Expected ~a, got ~a~n"
filter-spec result))))
---
Using ivar/proc allows me to apply the method set-filter! to a list.
If I'd used send, I'd have to put that information in arguments.
By using a list, I can put that information in one place, filter-spec,
which is used to supply data to set-filter!, and again when
checking the result.
-- Paul