All Questions

Filter by
Sorted by
Tagged with
1
vote
3answers
420 views

Does the Perfect Compiler trump source differences

Is it theoretically possible to create a perfect compiler for a language (for example C) meaning that if two different persons make two different implementations of the same algorithm then the ...
0
votes
1answer
398 views

AST design: Call is both expression and statement?

I'm designing the AST for a compiler and found that I don't actually know how to represent the Call node. Currently, the relevant part of the AST looks like this (where the arrows denote inheritance):...
23
votes
6answers
4k views

What is the common procedure used when compilers statically type check “complex” expressions?

Note: When I used "complex" in the title, I mean that the expression has many operators and operands. Not that the expression itself is complex. I've recently been working on a simple compiler to x86-...
79
votes
6answers
14k views

How does garbage collection work in languages which are natively compiled?

After browsing several answers an Stack Overflow, it is clear that some natively compiled languages have garbage collection. But it is unclear to me how exactly this would work. I understand how ...
21
votes
2answers
1k views

Is it possible to create a “bootstrapped” interpreter independent of the original interpreter?

According to Wikipedia, the term "bootstrapping" in the context of writing compilers means this: In computer science, bootstrapping is the process of writing a compiler (or assembler) in the source ...
2
votes
3answers
168 views

How are namespaces used in the stack during scope lookups?

I'm taking a comparative programming languages course and have learned the bare basics of variable scopes with respect to stack frames -- e.g. static and dynamic links, offsets, etc. as in the image ...
0
votes
2answers
238 views

Do some built-in functions loop behind the scenes?

I mostly code in C# & VB, but I think this question is pretty universal. I try to limit loops to increase performance. For instance, string functions that split the string into an array, or do a ...
0
votes
2answers
392 views

Abstract Syntax Tree with parent or not? [closed]

My question is as simple as the title says -- should I implement AST with parent or not? Currently I implemented it with parent -- the benefit of that approach is, that whatever I use, I can go up or ...
1
vote
1answer
904 views

How would a compiler turn an else-if cascade into a switch?

I don't like switch in C and its descendants. Maybe it's the need for a break or the clumsiness of the syntax requiring a shifting of mental gears, I don't know. Whatever the reason, I will almost ...
1
vote
2answers
173 views

Will a binary include methods that are not called in the source code?

[Potentially misleading title, but I'm not sure how best to word it.] Theoretical question on compilers and language design. Say I'm re-implementing a method in a code base. Instead of removing or ...
2
votes
2answers
246 views

Are there any practical uses of allowing recursive inclusion of a file?

I am currently implementing NASM-like preprocessor for my assembler, and I am wondering what is the correct way of handling recursively included files. From what I see, there are two ways to deal with ...
4
votes
9answers
748 views

Why are effect-less functions executed?

All the languages I know of would execute something like: i = 0 while i < 100000000 i += 1 ..and you can see it take a noticeable amount of time to execute. Why though, do languages do this?...