Having to do with issues arising when implementing a programming language.
Questions tagged [language-implementation]
141 questions
4
votes
1 answer
How do I work with doubles at the bit level in standard C89?
I'm toying with implementing NaN tagging in a little language implementation I'm writing in C. To do this, I need to take a double and poke directly at its bits.
I have it working now using union casting:
typedef union
{
double num;
unsigned…

munificent
- 11,946
- 2
- 38
- 55
4
votes
2 answers
Lua: understanding table array part and hash part
In section 4, Tables, in The Implementation of Lua 5.0 there is and example:
local t = {100, 200, 300, x = 9.3}
So we have t[4] == nil. If I write t[0] = 0, this will go to hash part.
If I write t[5] = 500 where it will go? Array part or hash…

happy_marmoset
- 2,137
- 3
- 20
- 25
4
votes
1 answer
IE8 JavaScript: select.options behaviour
I've today discovered some strange behaviour in IE8's implementation of the DOM select element's JavaScript 'options' property.
Given the following HTML:
And the javascript:
var sel =…

Benjamin Fox
- 5,624
- 5
- 19
- 19
3
votes
1 answer
where python store global and local variables?
Almost same as question Where are the local, global, static, auto, register, extern, const, volatile variables are stored?, the difference is this thread is asking how Python language implement this.

brike
- 313
- 4
- 10
3
votes
4 answers
How modulo and remainder should work in Scheme?
I'm reading R5RS spec and it shows this:
(modulo 13 4) ===> 1
(remainder 13 4) ===> 1
(modulo -13 4) ===> 3
(remainder -13 4) ===> -1
(modulo 13 -4) ===> …

jcubic
- 61,973
- 54
- 229
- 402
3
votes
1 answer
Why is Racket implementation so much faster than MIT Scheme?
The following code uses the Euclidean algorithm to calculate gcd(a,b) and integers s, t such that sa+tb=gcd(a,b) (for a Discrete Mathematics course). I coded it in C, and perhaps this will clearly illustrate the algorithm.
gcd.c:
#include…

Jonathan Lam
- 16,831
- 17
- 68
- 94
3
votes
1 answer
How does std::notify_all_at_thread_exit work?
According to cppref:
std::notify_all_at_thread_exit provides a mechanism to notify other
threads that a given thread has completely finished, including
destroying all thread_local objects.
I know the exact semantics of…

xmllmx
- 39,765
- 26
- 162
- 323
3
votes
2 answers
Why "there is no such thing as stack overflow" in Racket?
The following paragraph is from The Racket Guide (2.3.4):
At the same time, recursion does not lead to particularly bad
performance in Racket, and there is no such thing as stack overflow;
you can run out of memory if a computation involves too…

1MinLeft
- 93
- 7
3
votes
2 answers
Implement the internal processing for C #include directives
I need to think in the cleanest possible way to implement the functionality of the #include directive for a C compiler.
I only know how implement the external part of the processing: Get the '#' char at the beginning of the line to run a…

alt.126
- 1,097
- 1
- 9
- 22
3
votes
2 answers
Unicode strings in process memory
What is the most preferred format of unicode strings in memory when they are being processed? And why?
I am implementing a programming language by producing an executable file image for it. Obviously a working programming language implementation…

Cheery
- 24,645
- 16
- 59
- 83
3
votes
1 answer
What is the reason behind "get" method implementation of AtomicMarkableReference in java?
In java an AtomicMarkableReference can be used to update atomically an object reference along with a mark bit.
The javadoc states:
Implementation note: This implementation maintains markable references by creating internal objects representing…

Shadow Template
- 113
- 1
- 7
3
votes
1 answer
How does Angular know what to inject if I don't specify strings?
Consider this code:
angular.module('app', [])
.controller('MainCtrl', function ($scope) {
...
});
I know that to avoid problems with injection when the JS is minified, the array form of Dependency Injection should be…

Dan Dascalescu
- 143,271
- 52
- 317
- 404
3
votes
4 answers
What is an FFP machine?
In R. Kent Dybvig's paper "Three Implementation Models for Scheme" he speaks of "FFP languages" and "FFP machines". Apparently there is some correlation between FFP machines, and string-reduction on multiple processors.
Googling doesn't really…

Mark Bolusmjak
- 23,606
- 10
- 74
- 129
3
votes
4 answers
C/C++ Control Structure Limitations?
I have heard of a limitation in VC++ (not sure which version) on the number of nested if statements (somewhere in the ballpark of 300). The code was of the form:
if (a) ...
else if (b) ...
else if (c) ...
...
I was surprised to find out there is a…
user123456
3
votes
0 answers
Implementation of REPL/eval in a bytecode compiled language
I am in the process of creating a small language that is compiled to bytecode and run on a custom VM, the architecture of which has largely been influenced by what I've read about Python and Lua. There are two stacks - a data stack that stores…

jaz303
- 1,136
- 9
- 11