question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ordinary functions can override internal constructor access functions

See original GitHub issue

On the JS backend, a constructor compiles to a function with a name like Classname_constructorname. If you manually declare a function with that name after the class, it overrides the constructor function.

class C of c {
    shared new c {}
}
void \iC_c() {
    print("boom!");
}
shared void run() {
    print(C.c);
}
$ ceylon compile-js,run-js tmp
Note: Created module tmp/1.0.0
boom!
<null>

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
jvasileffcommented, Apr 21, 2016

feature?

0reactions
chochoscommented, May 6, 2016

ok now it’s done.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Calling virtual functions inside constructors - Stack Overflow
[...] In a constructor, the virtual call mechanism is disabled because overriding from derived classes hasn't yet happened. Objects are constructed from the ......
Read more >
Access Modifiers - C# Programming Guide - Microsoft Learn
All types and type members in C# have an accessibility level which controls whether they can be used from other code.
Read more >
Class inheritance - The Modern JavaScript Tutorial
We can override not only methods, but also class fields. Although, there's a tricky behavior when we access an overridden field in parent ......
Read more >
Contracts — Solidity 0.8.17 documentation
Internal functions can only be accessed from within the current contract or contracts deriving from it. They cannot be accessed externally. Since they...
Read more >
Virtual Function in C++ - GeeksforGeeks
They are always defined in the base class and overridden in a derived class. It is not mandatory for the derived class to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found