Having to do with issues arising when implementing a programming language.
Questions tagged [language-implementation]
141 questions
20
votes
2 answers
What Lisp is better at parsing?
I'd like to implement a Lisp interpreter in a Lisp dialect mainly as a learning exercise. The one thing I'm thrown off by is just how many choices there are in this area. Primarily, I'm a bit more interested in learning about some of the Lisps…

Jason Baker
- 192,085
- 135
- 376
- 510
19
votes
9 answers
Internal implementation of java.util.HashMap and HashSet
I have been trying to understand the internal implementation of java.util.HashMap and java.util.HashSet.
Following are the doubts popping in my mind for a while:
Whats is the importance of the @Override public int hashcode() in a HashMap/HashSet?…

peakit
- 28,597
- 27
- 63
- 80
18
votes
2 answers
How are arrays implemented in Perl?
The Perl array is an abstract data type. What's the internal mechanism for the Perl array? Is it implemented with dynamic array or linked list?
Since the array elements have random access, I would assume a dynamic array of pointers, or references…

Jason X
- 183
- 6
16
votes
1 answer
Why does binding affect the type of my map?
I was playing around in the REPL and I got some weird behavior:
Clojure 1.4.0
user=> (type {:a 1})
clojure.lang.PersistentArrayMap
user=> (def x {:a 1})
#'user/x
user=> (type x)
clojure.lang.PersistentHashMap
I thought that all small literal maps…

DaoWen
- 32,589
- 6
- 74
- 101
15
votes
5 answers
Does the range for integer values of a char depend on implementation?
I'm reading The C++ Programming Language and in it Stroustrup states that the int value of a char can range from 0 to 255 or -127 to 127, depending on implementation. Is this correct? It seems like it should be from -128 to 127. If not, why are…

108
- 1,631
- 3
- 19
- 25
14
votes
2 answers
Garbage collection implementation in compiled languages
When implementing precise garbage collection, there is always the issue of figuring out which words on the stack are pointers and which are other kinds of data such as integers or floating point numbers. Interpreted languages typically solve this…

rwallace
- 31,405
- 40
- 123
- 242
14
votes
2 answers
Understanding the implementation of memcpy()
I was looking the implementation of memcpy.c, I found a different memcpy code. I couldnt understand why do they do (((ADDRESS) s) | ((ADDRESS) d) | c) & (sizeof(UINT) - 1)
#if !defined(__MACHDEP_MEMFUNC)
#ifdef _MSC_VER
#pragma…

Angus
- 12,133
- 29
- 96
- 151
14
votes
1 answer
Why does `vector` implementation have multiple cases?
Here's clojure's definition of vector:
(defn vector
"Creates a new vector containing the args."
{:added "1.0"
:static true}
([] [])
([a] [a])
([a b] [a b])
([a b c] [a b c])
([a b c d] [a b c d])
([a b c d & args]
(.…

Matt Fenwick
- 48,199
- 22
- 128
- 192
13
votes
4 answers
Is there a Scheme implementation that parallelizes?
Is there a R5RS-or-higher Scheme implementation that does parallelization? For example, if I say to do:
(map (lambda (x)
(pure-functional-stuff x))
'(1 3 5 7 11 13))
it will process 1, 3, 5, and 7 simultaneously if the machine can do…

JasonFruit
- 7,764
- 5
- 46
- 61
12
votes
5 answers
A smart garbage collector for sharing subranges of arrays?
In this popular question about why substring takes O(n) in C#, one of the main answers provided argued that if a large array were allocated and substrings computed by having the new strings just reference a small slice of the array, the garbage…

templatetypedef
- 362,284
- 104
- 897
- 1,065
11
votes
2 answers
Compiling functional languages to C
Suppose you're compiling a functional language to portable C, and suppose also that for various reasons you want precise rather than conservative garbage collection. There is no portable way (perhaps no way at all in the general case) for the…

rwallace
- 31,405
- 40
- 123
- 242
11
votes
4 answers
Haskell: Why ++ is not allowed in pattern matching?
Suppose we want to write our own sum function in Haskell:
sum' :: (Num a) => [a] -> a
sum' [] = 0
sum' (x:xs) = x + sum' xs
Why can't we do something like:
sum' :: (Num a) => [a] -> a
sum' [] = 0
sum' (xs++[x]) = x + sum' xs
In other words why…

Abhisek
- 4,610
- 3
- 17
- 27
11
votes
6 answers
How does a macro-enabled language keep track of the source code for debugging?
This is a more theoretical question about macros (I think). I know macros take source code and produce object code without evaluating it, enabling programmers to create more versatile syntactic structures. If I had to classify these two macro…

Sean Woods
- 2,514
- 3
- 18
- 24
10
votes
5 answers
How to implement a practical fiber scheduler?
I know the very basics about using coroutines as a base and implementing a toy scheduler. But I assume it's oversimplified view about asynchronous schedulers in whole. There are whole set of holes missing in my thoughts.
How to keep the cpu from…

Cheery
- 24,645
- 16
- 59
- 83
10
votes
1 answer
Source code of implementation JavaScript internal methods
Is there a way to see the code behind a JavaScript's method? Not a javascript method from the website's .html or .js files, but JavaScript's internal methods.
For example:
How can I see how JavaScript calculates the offsetTop of an element?

Fistright
- 175
- 1
- 11