-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Meta-programming interface - ERC165 support #1447
Comments
This could be augmented by compile-time execution of certain pieces of code. It should be possible to execute |
Following |
I would prefer |
Using the above meta programming interface, ethereum/EIPs#165 can be implemented as a library:
|
@axic note that the type of |
Right, we need templates then 😉 |
I think it can be solved without templates too: library ERC165 {
function interfaceID(bytes4[] memory sigs) constant returns (uint)
{
uint mask = 0;
for (var i = 0; i < sigs.length; i++)
mask ^= uint(sigs[i]);
return mask;
}
}
contract Test {
function interfaceID() constant returns (uint) {
return ERC165.calculateInterfaceID(type(this).selectors);
}
} |
Now that ERC165 is further towards standardisation - shall we add some kind of high level support for this? |
An alternate solution to complete templates would be something like Ruby's mixins:
or
Basically these are very restricted templates: no template parameters are supported, except that |
Are there any more use-cases for that? Otherwise, I have the impression that it is too complicated and also too restricted at the same time. |
The best current solution I think still is this: #1447 (comment) I am also wondering what are use cases there are now for mixins vs. templates. It Whether we want any of that complexity. |
As a first impression I'm not a fan of the |
Yes, for this particular case, I think that may be the simplest and best solution indeed. |
Now we have Updated proposal:
I'm not sure |
Might be a waste of memory, but sounds good! |
They are in their current form, however in the future with compile time evaluated expressions all these would only exists during compile time in most of the real use cases. |
This issue has been marked as stale due to inactivity for the last 90 days. |
Hi everyone! This issue has been automatically closed due to inactivity. |
While this topic can be fairly big and we have a couple of issues open already here I only suggest a fairly small, non-intrusive addition:
to return a meta object (similar to
block
, etc.). This would have the following defined currently:.signatures
returnsbytes4[]
corresponding to the method signatures of the contract.name
returnsstring
as the name of the contractThe signatures could be utilised by proxy / filter contracts and for a way to implement interface checking between contracts (along the lines of ethereum/EIPs#165).
Two other possible methods:
.pragma(<key>)
returnsstring
of the actual pragma value or empty string if not set (or should the return type depend on the pragma type?).super
returnsmeta[]
corresponding to all the direct superclassesThe text was updated successfully, but these errors were encountered: