RemObjects Software Gears
 
       

Multipass Chrome

{#} by Carlo Kok 01/08/05 09:00:25 pm, 260 words, Categories: main
A problem I met before I started working on Chrome was circular references. A circular reference in Pascal happens when both units use the other one in its interface section.

unit File1;
Inteface
uses
File2;

type TClass1 = class
private

T1: TClass2;
end;

...
Implementation

end.


unit File2;
Inteface
uses
File1;

type TClass2 = class(TClass1)
private
end
;

...
Implementation

end.



The above example wouldn't compile in regular Pascal and the classes would have to be put in a single file to make it work.

In Pascal, the files contain interface and implementation sections. In the interface you declare types, functions, constants that are accessible from outside the file and in the implementation section you declare the implementation of these classes and methods. Generally Pascal compilers are single pass, referring to processing the file once before creating the output. Chrome, However, uses multiple passes over the interface section.

When we talk about a multipass compiler, we generally think about a slow c++ compiler, but multipass doesn't have to be slow. Chrome doesn't use header files like c++ does, instead it uses fast readable .Net assemblies as libraries.

When compiling, Chrome first reads the interface sections of all files, then goes over them as needed to resolve all types. This gives us advantages over other Pascal implementations.

It makes it possible to spread a namespace over multiple files. Because types are resolved after they are read, there are no dependency errors between the different files. All files are compiled at once.

Also it's possible to put a single class in each file without having any circular reference problems between the files.

Comments, Pingbacks:

No Comments/Pingbacks for this post yet...

Leave a comment:

Your email address will not be displayed on this site.
Your URL will be displayed.

Allowed XHTML tags: <p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, span, bdo, br, em, strong, dfn, code, samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small>
(Line breaks become <br />)
(Set cookies for name, email and url)
(Allow users to contact you through a message form (your email will NOT be displayed.))
This is a captcha-picture. It is used to prevent mass-access by robots.
Please enter the characters from the image above. (case insensitive)

 

Carlo Kok

Twitter

marc hoffman (follow)
    loading...
Mike Orriss (follow)
    loading...

Navigation

XML Feeds 

Who's Online?

  • Guest Users: 9