Skip to main content
11 votes
Accepted

Why is Smalltalk’s cascade operator not more common?

Depending on where you draw the line for "newer", there are some other examples. Dart has a very similar cascade notation in the form of a double dot: ...
Maldus's user avatar
  • 299
10 votes
Accepted

How can an object-oriented language support hot reloading of classes?

The Objective-C Runtime Objective-C has surprisingly strong runtime reflection capabilities, on par with that of JavaScript. Here's a couple ways you could do it with the Objective-C runtime library. ...
Bbrk24's user avatar
  • 9,672
9 votes
Accepted

Why does C++ require private methods to be declared with public ones?

As also explained by the other answer, all member variables need to be declared in the header, because by themself all types in C++ are value types. This implies that the compiler needs to know their ...
chrysante's user avatar
  • 848
9 votes

What are the different class-like constructs that languages use today?

Here's my attempt at categorising them. I've tried to cover the most significant differences between these constructs in different languages, and I've tried to choose language-agnostic terms; but ...
kaya3's user avatar
  • 22.4k
9 votes
Accepted

What options are there for code sharing/default implementations in a structurally-typed language?

I think this is equating nominal subtyping with inheritance too strongly, when code reuse and subtyping are really orthogonal axes that can be bundled together (as in C# class inheritance), but could ...
Michael Homer's user avatar
  • 15.3k
8 votes

Why do languages differ about when `super` must be called in a constructor?

There is a specific problem that this is trying to solve, which is to prevent code from outside of the constructor from observing an uninitialised object. The issue is that constructors are allowed to ...
kaya3's user avatar
  • 22.4k
7 votes
Accepted

Were there attempts to support triggering accessors on modifying subelements of properties?

This feature would violate the principle of compositionality, which holds that the meaning of a term is derived from the meanings of its subterms. Consider the following two snippets: ...
kaya3's user avatar
  • 22.4k
7 votes

What are the possible variations of the type of "this" or "self"?

Swift's covariant Self Expanding on @kaya3's answer, Swift has a special Self type that behaves differently depending on where ...
Bbrk24's user avatar
  • 9,672
7 votes

What are the advantages/disadvantages of making every class an instance of an Object superclass?

Drawback: Universal cluttered namespace With all classes as subclasses of common type with methods then that means all classes will always have these methods, even where they are invalid in some ...
André L F S Bacci's user avatar
6 votes

What are the advantages/disadvantages of making every class an instance of an Object superclass?

This 'super' superclass can define methods that may be important or beneficial for all other classes to implement. These may be commonly used operations. For example, printing to the standard output ...
FireTheLost's user avatar
  • 1,651
6 votes

What are the advantages/disadvantages of making every class an instance of an Object superclass?

Ignoring Static Types Static typing is nice. But sometimes it gets in your way. Sometimes you really, genuinely do know nothing about an object, other than that it exists. Maybe you just deserialized ...
Silvio Mayolo's user avatar
5 votes

Is it meaningful to disallow member variables in interfaces?

So, theoretically it's possible, and you could argue that some languages (such as Scala via traits) already support them. But there are a lot of drawbacks and special cases to consider. The problem ...
tarzh's user avatar
  • 4,509
5 votes
Accepted

Is it correct that Python does not encourage us to read objects's content?

TL;DR Javascript was not at first intended to be a general purpose programming language, Python was. Longer Answer Javascript was developed in 1995 to add small amounts of behavior to web pages that ...
Jared Smith's user avatar
5 votes

Why does C++ require private methods to be declared with public ones?

The private attributes may effect the position of public attributes. If you have a class like this: class A { public: int a; } Here, ...
mousetail's user avatar
  • 9,559
5 votes

How can runtime type checks be implemented?

Fat Pointers A "fat pointer" is a pointer that stores additional data besides an address. For the purposes of dynamic dispatch and type checking, this data can be a pointer to a vtable which ...
Olive's user avatar
  • 508
4 votes
Accepted

Virtual functions from two classes

This feels more like a stackoverflow Q than a PLDI one as you seem to be talking about how to use a feature not realize it in a language. I will assume you mean the latter. If I've interpreted your ...
Bruce Adams's user avatar
  • 3,002
4 votes

Why is Smalltalk’s cascade operator not more common?

One issue of this feature is implicit shadowing. JavaScript has a with statement that works like a cascade operator that is no longer recommended and has been ...
Jasmijn's user avatar
  • 1,409
4 votes

Are there OO languages which implement objects as persistent data-structures?

Are there examples of languages which have tried to implement objects as persistent data structures? Objects generally have a handful of fields, whose names and types are fixed for all objects of a ...
kaya3's user avatar
  • 22.4k
4 votes

What are the possible variations of the type of "this" or "self"?

This isn't a complete answer to the question, but a similar issue is common when methods are designed for chaining. For example, in Java: ...
kaya3's user avatar
  • 22.4k
3 votes

Were there attempts to support triggering accessors on modifying subelements of properties?

Proxy pattern with bubbling There is a solution for this, in the form of proxy patterns or proxy objects. That is, a new object that wraps around normal objects, and provides additional functionality ...
André L F S Bacci's user avatar
3 votes
Accepted

Strongest criticisms of object-oriented languages?

A tremendous amount here depends on what object oriented language you look at. In the specific case of C++, it also depends quite heavily on how you decide to use it. If you look carefully, you can ...
Jerry Coffin's user avatar
3 votes
Accepted

Can final and full lattice type theory be combined?

I think this is fine. Normally with subtyping you have an open-world assumption: for some type $T$ you can’t assume that there’s no subtype $S \le T$, so even if you know $x : T$, you can’t for ...
Jon Purdy's user avatar
  • 3,648
3 votes

Should comparison operators check whether their arguments are the same object?

It depends. Generally, we want a == a to hold true, so == represents an equivalence relation. In that case, using reference ...
Jasmijn's user avatar
  • 1,409
2 votes

How do I Implement User-Defined Classes?

Functions and Prototypes This is what JavaScript does. Consider this modern TypeScript class: ...
Bbrk24's user avatar
  • 9,672
2 votes

How can an object-oriented language support hot reloading of classes?

This is a feature of the language Erlang and the library functions known as OTP. The combination allows classes written following certain guidelines to be upgraded on the fly. During the upgrade ...
ghellquist's user avatar
2 votes

How should I represent objects under prototype-based inheritance?

I think a chain of hash-maps works fairly well. You can optimise a little bit by pre-resolving the string lookups to indexes in the map. The Wren language's VM does this. Every object gets allocated a ...
springogeek's user avatar
2 votes

How should unapplied method references be handled?

C++ has std::mem_fun() to turn a pointer-to-member-function into a function object: ...
G. Sliepen's user avatar
  • 1,599
2 votes

How to design interfaces to mimic haskell-like type classes in an object oriented language?

If you can declare a type to be a member of a class after the type is declared, then what this means is that all of the information required by that membership (e.g. virtual dispatch tables) cannot be ...
Pseudonym's user avatar
  • 5,686
1 vote

Is it meaningful to disallow member variables in interfaces?

Tyr actually has this for several years now. An example can be found here. In contrast to what the other answers say, there is a straight-forward extension of common interface implementations for ...
feldentm's user avatar
  • 2,418
1 vote

Why do languages differ about when `super` must be called in a constructor?

Computation symmetry on constructors Say, you have two classes, MultipleOfTwo and MultipleOfFour. The construct of MultipleOfTwo ...
André L F S Bacci's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible