Questions tagged [late-binding]

Late binding is a mechanism in which the method being called upon an object is looked up by name at runtime.

Late binding is a mechanism in which the method being called upon an object is looked up by name at runtime.

The specific type of a late bound object is unknown to the compiler at compile time. This is contrasted with early binding, where relationships between objects, methods are properties are established during compile time.

It is expected that questions tagged specifically relate to programming using late bound code. You should also tag your post with the specific programming language being used.

Example (VBA):

' late bound objects are declared As Object
Dim obj As Object
Set obj = CreateObject("Excel.Application")

Related Tags:

353 questions
161
votes
10 answers

How do lexical closures work?

While I was investigating a problem I had with lexical closures in Javascript code, I came along this problem in Python: flist = [] for i in xrange(3): def func(x): return x * i flist.append(func) for f in flist: print f(2) Note that…
Eli Bendersky
  • 263,248
  • 89
  • 350
  • 412
149
votes
8 answers

What exactly are late static bindings in PHP?

What exactly are late static bindings in PHP?
Sarfraz
  • 377,238
  • 77
  • 533
  • 578
89
votes
7 answers

Early and late binding

I'm trying to get my head around when early/late binding occurs in C#. Non-virtual methods are always early bound. Virtual methods are always late bound: the compiler inserts extra code to resolve the actual method to bind to at execution time and…
Josh
39
votes
6 answers

VB.NET: impossible to use Extension method on System.Object instance

Can I make an Extension method for all the subclasses of System.Object (everything)? Example: Public Function MyExtension(value As Object) As Object Return value End Function The above functions won't work for object instance: Dim…
Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
33
votes
10 answers

Cast sender object in event handler using GetType().Name

I have an event handler for a Textbox and a RichTextBox. The code is identical, but In handler #1 I do: RichTextBox tb = (RichTextBox)sender In handler #2 accordingly: TextBox tb = (TextBox)sender Doing so I can fully manipulate the sending…
tfl
  • 1,011
  • 2
  • 12
  • 21
28
votes
6 answers

Does C# .NET support IDispatch late binding?

The Question My question is: Does C# nativly support late-binding IDispatch? Pretend i'm trying to automate Office, while being compatible with whatever version the customer has installed. In the .NET world if you developed with Office 2000…
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
23
votes
8 answers

Option Strict On and .NET for VB6 programmers

I'm preparing a class on Visual Basic 2005 targeting Visual Basic 6 programmers migrating to the .NET platform. I would like a word of advice about whether to recommend them to always enable Option Strict or not. I've worked exclusively with C-style…
Enrico Campidoglio
  • 56,676
  • 12
  • 126
  • 154
22
votes
2 answers

How do I dynamically load raw assemblies that contains unmanaged code?(bypassing 'Unverifiable code failed policy check' exception)

I'm going to give an example of using System.Data.SQLite.DLL which is a mixed assembly with unmanaged code: If I execute this : var assembly= Assembly.LoadFrom("System.Data.SQLite.DLL") No exceptions are thrown, but if I do this : var…
Thiago Padilha
  • 4,590
  • 5
  • 44
  • 69
20
votes
3 answers

PHPDoc and late (static or dynamic) binding

Most PHP IDEs rely on phpdoc to get hints about the type of an expression. Yet, I use frequently this pattern, which doesn't seem to be covered: class Control { private $label = ''; /** @return ??? */ public static function Make(){…
linepogl
  • 9,147
  • 4
  • 34
  • 45
20
votes
8 answers

Get a static property of an instance

If I have an instance in PHP, what's the easiest way to get to a static property ('class variable') of that instance ? This $classvars=get_class_vars(get_class($thing)); $property=$classvars['property']; Sound really overdone. I would…
commonpike
  • 10,499
  • 4
  • 65
  • 58
20
votes
6 answers

Early binding vs. late binding: what are the comparative benefits and disadvantages?

When discussing the evolution of computer languages, Alan Kay says that the single most important attribute of his Smalltalk is late binding; it gives the language its malleability and extensibility, and allows inappropriate coupling to be…
dkretz
  • 37,399
  • 13
  • 80
  • 138
14
votes
3 answers

Is it possible to overuse late static binding in PHP?

Starting with version 5.3, PHP supports late binding for static methods. While it's an undoubtedly useful feature, there are only several cases where its use is really necessary (e.g. the Active Record pattern). Consider these examples: 1.…
Ignas R
  • 3,314
  • 2
  • 23
  • 27
13
votes
3 answers

Question about CreateObject() in VB6 / VBA

I can do this: Dim fso As New FileSystemObject or I can do this: Dim fso As Object Set fso = CreateObject("Scripting.FileSystemObject") How do I know what string to use for CreateObject? For example, how would I know to use the "Scripting." part…
Shane Miskin
  • 1,911
  • 2
  • 22
  • 30
13
votes
5 answers

Interpreted vs. Compiled vs. Late-Binding

Python is compiled into an intermediate bytecode(pyc) and then executed. So, there is a compilation followed by interpretation. However, long-time Python users say that Python is a "late-binding" language and that it should`nt be referred to as an…
user277465
13
votes
6 answers

Why should I prefer OSGi Services over exported packages?

I am trying to get my head around OSGi Services. The main question I keep asking myself is: What's the benefit of using services instead of working with bundles and their exported packages? As far as I know it seems the concept of Late Binding has…
Jens
  • 20,533
  • 11
  • 60
  • 86
1
2 3
23 24