In which language is F#'s compiler written?
I've heard that F#'s compiler is written in F# :)
(each next version of F# compiler is written on its previous version)
But:
1. Can't google if it's true.
2. If it's true, in which language is the first version of the F# compiler written?
The F# compiler is written in F#. The source code is available.
It was originally bootstrapped years ago using OCaml, I believe (and perhaps a little C++ as well). (There is still a non-trivial subset of F# that cross-compiles with OCaml, though the F# compiler source base has long since diverged from that.)
The current implementation always uses an LKG (last-known-good) set of binaries (.NET DLLs and EXEs) to bootstrap itself when building from source.
Related
I'm a newbie in Delphi, using Delphi 2007. I am learning things related to COM programming, in order to make a basic plugin to a program called Retail Pro. I have a little of background in .NET (C#, ASP), NetBeans (Java, JSF) and PHP.
Anyway, I'm following this intro tutorial to COM Programming :
An Introduction to COM Programming with Delphi
At second and third parts of the 5th lesson about Variant Arrays, there are sample codes to download. Here is the sample code of second part:
http://delphi.about.com/library/weekly/code/src122104_sample.zip
When I compile the code, it gives me a lot of errors of undeclared identifier (VarType, VarArrayCreate, VarArrayLowBound, etc). Is there some class to add in the uses section in order to be able to compile this piece of code?
The code is missing a unit from the uses clause. That unit is named Variants and contains all the symbols that the compiler cannot find. Add that unit and the code will compile.
I had know the difference between F# library and .NET library when I called their functions.
But when I saw the statement "printfn" in VS 2010 object browser, I saw only the "public static T PrintFormatLine(... format)" instead of "printfn".
Why has the statement "printfn" in F# library different name in VS2010 object browser?
How can I call functions in F# library, if there aren’t documents for the F# library, because the names in VS 2010 object browser are totally different?
The printfn function in the F# core library is annotated with a special attribute CompiledName that specifies the name of the function in a compiled form:
[<CompiledName("PrintFormatLine")>]
let printfn fp = ...
What is this good for? I think the motivation is that the FSharp.Core.dll library should follow the usual .NET naming guidelines. However, F# naming guidelines are a bit different (lowercase names are allowed, etc.), so the attribute is used to make the library look more like ordinary .NET library.
I don't think this is something that users of F# would use themselves. If you're writing code that will be used from C#, write it in a C# friendly style and if you're writing code that will be used from F#, follow the F# naming guidelines.
I'm pretty new to Delphi and I'm trying to use the DEHL Collections library. (see http://code.google.com/p/delphi-coll/ ) I'm have a little trouble with it from the IDE perspective. It compiles and runs correctly, but Delphi XE shows errors anywhere I use the HashSet library. The biggest grievance is that is prevents me from using code completion.
The first location I get the error is in an object declaration:
uses
SysUtils, Windows, Collections.Base, Collections.Sets, Collections.Lists,
adscnnct, adstable,
uOtherClass;
type
OneClass = class(OtherClass)
private
_bad: THashSet<string>; // THashSet underlined
_good: TList<string>; // No problems
end;
The error states: "Type arguments do not match constraints"
I don't think it's configuration as I can use TList just fine, but here is how I set it up: I've copied the library to Projects/Libs/DeHLCollections/Library and compiled the library to Projects/Libs/bin. I've included the bin directory in my global library path, which got it to compile and run. I have tried adding everything (/libs, /DeHLCollections, /Library) to it as well in hopes of getting the IDE to help me out, but it doesn't seem to be helping.
Anyway to fix this, or do I just have to deal with it?
Using DeHL Collections version 1.1.1.119
Welcome to the troubles with using Generics laden code. DeHL and generics work a lot better in Delphi XE than in any previous Delphi version, but that's not the same as it "not having any problems". The problems I experience are exactly like yours.
My opinion is that DeHL shows every sign of having been written by a master delphi programmer, and that it's a thing of beauty, in some ways. It's also a source of great pain, through no fault of its own.
Delphi contains not one or two, but at least three (maybe four?) separate parsers, including the full compiler parser, and a few IDE-parsers used for things like Error Insight (the errors you see even before you build) and the code completion data parser. Each has different language support limitations with regards to generics. It is possible perhaps that DeHL could be written to avoid parser problems with all the various Delphi parsers. I have not seen a guide ever written that shows the limitations, but I wouldn't be surprised if complex type declarations in the form TSomething<TSomething<ISomethingElse>,TBar<IFoo>> breaks more than a few of those parsers.
If you intend to use Generics very heavily, you may as well turn off Code Completion and Error Insight. You might also want to save often, and be prepared to experience a lot of compiler problems. And don't try to compile generics-heavy code and put it in packages either. I have experienced a lot of URW and AV (internal compiler faults) when I write generics based code. I find that the Delphi compiler team is great at fixing whatever gets reported, but that the Generics are really most stable for me when I restrict myself to using the Generics.Collections that come with Delphi, and not using other generics based code. It seems it is possible to write stuff using the generics features, that the IDE and two-way tools, and code-completion is not yet fully ready to handle. That means, phenomenal cosmic Generic powers come at a cost to the classic RAD IDE productivity features.
That being said, the latest DeHL sources from Subversion work fine for me and build and run with no errors, but the most recent source ZIP of the entire DeHL collection had problems for me.
I expect that over the next few releases of Delphi, whatever issues have been found (and DeHL seems to be a great place to push the boundaries, and that's one of the reasons i'm a big fan of it) will be fixed, and you won't be wondering why heavy-generics break your IDE features, because they'll all be working again.
Today I happened to compile, using Delphi 7, a code with a class definition like this
type TAudioStream = class helper of TStream;
and, to my astonishment, the compiler spits
"System unit out of date or corrupted: missing 'TClassHelperBase'".
It looks like Delphi7 has already some reserved usage of the helper word.
Delphi introduced Helper classes in Delphi 8. They were intended for binding VCL to .Net. So, is Delphi7 prescient?
I'm not sure if this a real question. Reservation of keywords for future implementation is a common practice. The roadmap and the planned features for Delphi 8 should be specified at the release date of Delphi 7. So yes, I think Delphi 7 is prescient in this case.
Remember that Delphi 7 included the ".Net preview compiler." Delphi 7 was aware of some upcoming features, and evidently, it was even somewhat aware of the implementation of those features — it knew enough to expect certain things to be in the System unit and to complain when they weren't present.
It is quite common for language designers to reserve certain words for future use. class and interface, for example, have been reserved words in JavaScript for … what, ten years now … even though they aren't expected to be used for another couple of years. goto is a reserved word in Java, even though it is never expected to be used.
It is also quite common for compiler writers to implement features for future use. Generics, for example, were already implemented in Sun's Java 1.2 javac compiler, even though they weren't added to the language specification until Java 5.
I need a complete Object Pascal syntax (preferably Delphi 2009). Some of the syntax is given by the help files, but not all information is provided. So I started collecting loose bits of information. Recently I added these to a more or less complete syntax description (EBNF like).
Although it looks extensive, there are still bugs and I'm sure parts are missing (specially in the .NET syntax). So I'm asking the SO Delphi community. Do you have any information or can you correct the errors? In return I provide the complete syntax to the community. It probably saves you some time ;-).
In the future, I like to do the same for other languages (Like C#/C++/Java).
The syntax description I already have is given: My Syntax sofar. Or if you like a Text version. (The XHTML is generated from the text version).
Please note that the syntax focusses on the syntactical part, because the lexical part is not really a problem.
Update
I have a new version of the Delphi Syntax. html version. It includes al versions including 2009. Prism extentions are still on the todo list. And I'm not sure if I'm going to keep them together.
For the real purists, it also contains the full assembler code (which does not support the full 100% of the intel set but only a few instructions are missed.).
Try this: DGrok - Delphi grammar
There is no complete, published syntax for Delphi. Bear in mind that .net and win32 delphi have different syntaxes.
This project has hand-build Delphi parser in it. And lots of test cases of code that compiles but pushes the limits of the syntax.
Delphi 7's grammar is in the back of the Object Pascal book.
You mean for a few thousand dollars they don't even send you that? Do they even send you a 6' x 6' poster?
This might be a good help. It is the parser used in TwoDesk's Castalia.
What exactly are the bugs and functionality you're missing?
From scanning over your document, it seems you mingle syntax and semantics. I do not understand why to distinguish between SimpleTypeFloat and SimpleTypeOrdinal on a syntactic level, or code operator precedence as syntactic feature in AddOp and MulOp. true, false, nil are identifiers just as any variable name you choose.
You could always read the source to the Free Pascal Compiler. It supports Object Pascal.