` Threading issues with files in methods - 2 (Alexey Solovjev) - Icetips Article
Icetips - Templates, Tools & Utilities for Clarion Developers

Templates, Tools and Utilities
for Clarion Developers

Icetips Article

Back to article list   Search Articles     Add Comment     Printer friendly     Direct link  

Clarion 6: Threading issues with files in methods - 2
2003-01-21 -- Alexey Solovjev
 
Hello, > does this means we can have no files declared anymore in class methods ? No. Class methods are normal procedures just with slightly another syntax, one predefined parameter. But up to 2 methods per class are special: constructor and destructor. They are invoking automatically when an instance they called for is created or to be destroyed. The common rule is that code can't assume any specific state of data that has not been initialized yet. This is true for any code and any kind of data, not for FILEs within constructor. For example, one can write following code ===== A CLASS,TYPE Construct PROCEDURE .... END B CLASS,TYPE Construct PROCEDURE .... END InstA A InstB B .... A.Construct PROCEDURE CODE .... B.Construct PROCEDURE CODE ===== From the point of syntax, all is correct but either InstA or InstB will use another one before it has been initialized and therefore this code is wrong. Absolutely the same thing happens with FILEs declared locally in the constructors of not-threaded instances of some classes: code tries to use data that has been initialized. I have an idea how to change the compiler and the RTL to allow programs like yours run without faults because of initialization but this would be an allowance to violate rules in very particular situations. Program should not violate rules. To summarize: - you can have FILEs declared locally in any method but constructor - you can have FILEs declared locally in constructors of classes if their instances are threaded - if you need in a FILE within a constructor of some class that has not-threaded static instances, that FILE should be declared out of constructor method. Alexey Solovjev


Today is April 18, 2024, 11:05 pm
This article has been viewed 35109 times.
Google search has resulted in 7 hits on this article since January 25, 2004.



Back to article list   Search Articles   Add Comment   Printer friendly

Login

User Name:

Password: