Dynamic languages allow dispatching with and invoking on values from variables whose values are only known at run-time. Contrasting examples in Perl:
class names
constant
Foo::Bar->some_method Foo::Bar::->some_method 'Foo::Bar'->some_method
These are all identical, except the first one is an edge case. If there's a subroutine defined in scope with that name, the dispatch happens on its return value, which leads to difficult to understand bugs. The quoted versions are always safe.
dynamic
my $class_name = 'Foo::Bar'; $class_name->some_method
method names
constant
Some::Class->foo_bar
dynamic
my $method_name = 'foo_bar'; Some::Class->$method_name
function names
constant
foo_bar; (\&foo_bar)->()
dynamic
my $function_name = 'foo_bar'; (\&$function_name)->()
I wonder, how do languages whose variable names have no sigils (normally, or at all) deal with these problems, specifically how did their language designers disambiguate the following?
- resolving class name
FooBar.some_method
where classFooBar
might be name literal or a variable whose value is a class name - dispatching to
SomeClass.foo_bar
where methodfoo_bar
might be name literal or a variable whose value is a method name - invoking
foo_bar
where the function might be a name literal or a variable whose value is a function
I'm primarily interested in the three languages mentioned in this question's tags, but if you know a different dynamic language with no sigils, you can answer too.