dynamic-dispatch Questions

4

Solved

I've encountered a problem that is explained in the code below (Swift 3.1): protocol MyProtocol { func methodA() func methodB() } extension MyProtocol { func methodA() { print("Default method...
Playhouse asked 22/6, 2017 at 15:8

2

Solved

I am reading the book Object Oriented Programming in Common Lisp from Sonja Keene. In chapter 2, the author says: The procedure for determining which methods to call and then calling them is calle...
Sphygmomanometer asked 9/6, 2021 at 1:30

0

I think that I almost understand what will be static or dynamic dispatch. As far as I know, struct instance with struct type will be always static dispatch. struct A { func yo() { print("A&q...
Lowenstern asked 16/4, 2021 at 12:5

1

Solved

Why is for-in slower than while in swift debugging mode? I wrote this. Thanks for people who answer to me, I could have learned Seqeunce and IteratorProtocol. So I implemented custom type ( School ...
Hexamerous asked 10/4, 2021 at 9:31

6

Coming form a C++/Java/C# background I was expecting to see virtual methods in Swift, however reading the swift documentation I see no mention of virtual methods. What am I missing? Due to large n...
Severe asked 3/6, 2014 at 11:29

2

Solved

Background Suppose I am to implement a simple decorator @notifyme that prints a message when the decorated function is invoked. I would like the decorator to accept one argument to print a customiz...
Bolan asked 7/10, 2020 at 17:7

0

Functions new_foo1 and new_foo2 return the same trait Foo using different patterns. I don't see any functional difference between them besides new_foo1 being more verbose. Is there a preferre...
Disavowal asked 22/9, 2020 at 8:33

0

I originally encountered this issue when attempting to create a Rayon ParallelIterator that a flat_map operation was applied to a dynamic number of times see this post on the Rayon issue tracker. ...
Vergievergil asked 24/10, 2019 at 12:33

2

Solved

Consider this code: class base{ T* obj=new T[40]; //... public: base(){/*...*/} virtual ~base(){ delete[] obj; //... } ... }; class derived : public base{ T* obj2=new T[20]; //... public...
Distill asked 6/9, 2019 at 5:26

3

As the Gang of Four states it in "Design Patterns": "it's often said that 'inheritance breaks encapsulation'", paraphrasing Snyder in "Encapsulation and Inheritance in Object-Oriented Programming L...

1

Solved

I was playing with a dyn traits introduced in Rust 1.27 and stumbled into this compiler error: error[E0433]: failed to resolve. Use of undeclared type or module `dyn` --> src\main.rs:1:30 | 1...
Occultation asked 27/6, 2018 at 21:51

2

Solved

Does the following bit of code use dynamic dispatch as it's understood in C++ or Java? As I understand, at the last line, compiler cannot possibly know at compile time which implementation of (==)...
Handyman asked 22/4, 2018 at 6:18

2

Solved

I am coming to Go from Java and some things confuses me. For example, let's consider the following code: package main import ( "fmt" ) type I interface { Do() MegaDo() } type A struct { } ...
Sicken asked 5/3, 2018 at 15:37

2

Solved

Decompile Scala code: why there are two overridden methods in the derived class? class A { private var str: String = "A" val x: A = this override def toString(): String = str def m1(other: A...

1

Solved

I'm writing an error logger using Crashlytics and I've come up against an issue that is making me question my understanding of protocols and dynamic dispatch. When recording non fatal errors using...
Delmadelmar asked 19/1, 2018 at 15:56

1

Solved

By chance, I discovered that you can do this without the compiler complaining: extension Date { var timeIntervalSinceNow: TimeInterval { return 1000 } } What's weirder, is that this actually ...

2

Solved

I have the following code: extern crate futures; // 0.1.24 use futures::Future; use std::io; struct Context; pub trait MyTrait { fn receive(context: Context) -> Future<Item = (), Error =...
Pansie asked 15/7, 2017 at 10:9

3

Solved

There are too many associated names: Early and Late Binding, Static and Dynamic Dispatch, Runtime vs. Compile-time Polymorphism, etc. that I don't understand the difference. I found a clear expla...

1

According to Apple : When you mark a member declaration with the dynamic modifier, access to that member is always dynamically dispatched. Because declarations marked with the dynamic modifier are...
Sneed asked 16/4, 2015 at 21:42

4

Solved

I'd like to be able to dispatch different implementations of a function, based not only on the type of the first parameter, but based on arbitrary predicates. Currently I have to do it like so: de...
Multipara asked 22/12, 2015 at 22:39

2

Solved

First of all, I understand that this question has no application in real world, I'm just curious. Imagine we have a class with a singleton method: class Foo def self.bar end end If we call Fo...
Adder asked 2/8, 2015 at 19:10

2

Solved

s->duplicate() returns an object of type Box*, but I'm getting an error initializing it with Box*. It looks like it's being converted back to Shape*. What is the point of having covariant return...
Harvestman asked 25/1, 2015 at 3:20

4

Solved

If the virtual function table is the same for all objects of the class, then why can't the pointer to that table (vfptr) be static and be shared across all the objects?
Sump asked 23/8, 2014 at 16:2

1

Solved

I found some explanations of open/closed recursion, but I do not understand why the definition contains the word "recursion", or how it compares with dynamic/static dispatching. Among the explanati...

3

Solved

Problem I am working with an already existing library, to the source code of which I do not have access. This library represents an AST. I want to copy parts of this AST, but rename references to...
Overplay asked 27/12, 2012 at 22:33

© 2022 - 2024 — McMap. All rights reserved.