Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is F# compiler a single-pass compiler?

I look around the web and only find 1 mention about F# using one pass compilation in a personal blog, not in official docs.

From my experiences so far it seems that F# uses one pass compilation such that you can only reference types or functions which have been defined either earlier in the file you’re currently in or appear in a file which is specified earlier in the compilation order.

Is this statement true?

like image 575
MiP Avatar asked Apr 18 '17 04:04

MiP


1 Answers

You'd need to define what a "pass" means in order to answer this question.

Many compilers are what are termed multi "phase" which means the distinct stages in the transformation of the source text into executable machine code or IL code.

I think the term "pass" is outdated and refers to very early compilers that may have read the actual source files more than once as part of their processing, real commercial grade compilers almost certainly don't do this or need to do this.

For example I worked on a PL/1 (aka PL/I) compiler for Windows many years ago and that went through several phases, these were:

  • parse - consume source file(s) and create parse tree
  • declarations - resolve identifiers in parse tree to declared names
  • optimize - analyze the parse tree and restructure it optimally.
  • codegen - analyze the parse tree and generate an OBJ file.

Most compilers today pretty much do this (whether in distinct phases or not - but they do the same work).

like image 59
Hugh Avatar answered Sep 25 '22 15:09

Hugh