Questions tagged [language-implementation]

Having to do with issues arising when implementing a programming language.

141 questions
3
votes
1 answer

Default size of priority queue in java

I am wondering why the default size of a PriorityQueue in Java is 11. I looked up the implementation and it made things more confusingly for me. The priority queue is implemented as a heap. Its capacity is adjusted using this function: /** *…
Dimitris Leventeas
  • 1,622
  • 2
  • 16
  • 29
2
votes
3 answers

Shift operation implementation in java

I recently used the shift operators in Java and noticed that the >> operator does not have the same meaning as >> in C. In Java >> is Signed shift that keeps the first bit at the same value. In Java the equivalent to C shift is the >>> operator. The…
nist
  • 1,706
  • 3
  • 16
  • 24
2
votes
4 answers

X is enum - is this according to spec?

Test if an object is an Enum discusses testing an object with is Enum to see if it contains an enum value. Is this specified anywhere in the spec? The entry on is (7.10.10 in Version 4.0) lists the following possible right-hand values: anonymous…
sq33G
  • 3,320
  • 1
  • 23
  • 38
2
votes
1 answer

In Go sync.Map why this part of implementation is inconsistent or do I misunderstand something?

sync.Map is a concurrent-safe map implementation. the type of raw maps in sync.Map actually is map[any]*entry. When we call Map.LoadOrStore and the entry exists, entry.tryLoadOrStore is invoked and the following is the code of this function func (e…
Hokulala
  • 33
  • 4
2
votes
1 answer

Does handling recursion need special treatment when designing a compiler?

Function calls are handled via a stack data structure. Is this enough for supporting recursion?
2
votes
2 answers

Do Ada 83 exceptions include resource cleanup?

Ada 83 was one of the first languages to have exceptions. (I want to say 'the first', but one thing I have learned from looking into the history of technology is that there is almost always an earlier X.) From the implementation perspective, the…
rwallace
  • 31,405
  • 40
  • 123
  • 242
2
votes
1 answer

Different ways of implementing a coroutine

I can currently think of two ways of implementing a coroutine: Whenever a coroutine is started, instead of storing local variables on stack, get a piece of memory from heap and use it to store local variables. This way, local variables are not…
2
votes
1 answer

Mechanism by which Common Lisp compiles and loads code into image

Recently I've been reading on how modern OS load executable programs and allocate memories for them. Unfortunately, I only have a computer science book in Russian as a reference, so, please, correct me if I am wrong, but it appears that modern OS…
mobiuseng
  • 2,326
  • 1
  • 16
  • 30
2
votes
1 answer

How to reliably detect exotic objects in JavaScript?

Is there any way to reliably whether a JavaScript object is an exotic object type, and if so what its type is? By "exotic", I mean (for the purposes of this question) anything which is could not be created using Object.create. This includes…
2
votes
3 answers

What are the possible ways to do garbage collection in concurrent systems?

I need to write a garbage collector for an interpreter that will support concurrency, but I can only find information about garbage collection without anything to do with concurrency. Are there specific methods for garbage collection of objects in…
josh
  • 997
  • 1
  • 8
  • 13
2
votes
1 answer

What is the behavior of super() and __init__() in class inherited from object?

Using python 2.7 with new class style, if my class inherits from Objectclass, what is the behavior of super(ClassName, self).__init__() ? What I mean is, what happens behind the scenes ? What is the difference if I omitted it ? An example above: …
ViniciusArruda
  • 970
  • 12
  • 27
2
votes
1 answer

Advantages and drawbacks to implementing core methods of a scripting language in the underlying language

Background: I am writing a scripting language interpreter as a way to test out some experimental language ideas. I am to the point of writing the core set of standard methods (functions) for built-in types. Some of these methods need to directly…
2
votes
4 answers

Why aren't CPython Dicts affected by Hash Values for Negative one and negative two

Hash tables are supposed be high-performance mappings, and because Python dicts are implemented with hash tables, they're also highly performant. But I've encountered a strange result when looking at hash values of negative integers. >>> for i in…
2
votes
4 answers

Compiling via C/C++ and compiler bugs/limits

I'm looking at the possibility of implementing a high-level (Lisp-like) language by compiling via C (or possibly C++ if exceptions turn out to be useful enough); this is a strategy a number of projects have previously used. Of course, this would…
rwallace
  • 31,405
  • 40
  • 123
  • 242
2
votes
3 answers

ArrayList internal implementation

Hopefully this is not a duplicate. Before anything, I know ArrayList are not the best choice but this is just curiosity. Simply, I was wondering about the implementation of ArrayList. I looked and figured out it uses an array for storage. For…
Everts
  • 10,408
  • 2
  • 34
  • 45