[fpc-pascal] Weird interface behavior

leledumbo leledumbo_cool at yahoo.co.id
Sun Jan 23 15:05:32 CET 2011


WARNING: it won't be simple

I'm using visitor pattern in my project and to the best of my knowledge, the
visitor should be implemented as an interface. After everything goes
compiled, I found out a weird behavior. That is, all the change during
accept-visit is gone after control goes back to the initiator (first
accept). Even worse, I can't free the object! It causes access violation.

I attach the project that shows this. The project is quite big, but you can
focus to only two units (more precisely, to their interface as seen in the
attached diff): ast and cg. I create two versions of both units (the other
using class with abstract methods) and their diff is attached. Try compiling
with both versions (by renaming the one you want to compile to the right
name, e.g. without .tmp suffix). Ensure linguc.lpr on line 118 is commented
when you're using the interface version (it causes access violation as I
state above).

Attachment:
http://free-pascal-general.1045716.n5.nabble.com/file/n3353651/intf.zip
intf.zip 

-- 
View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Weird-interface-behavior-tp3353651p3353651.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.



More information about the fpc-pascal mailing list