The Solidity Contract-Oriented Programming Language - By chatting here you agree to the https://github.com/ethereum/solidity/blob/develop/CODE_OF_CONDUCT.md
Is it possible to use interface functions as types?
e.g.
interface Foo {
function myFunction() external;
}
contract Contract {
function myOtherFunction(Foo.myFunction func) external;
}
The code above does not compile
Hello all, sharing the complex number library I wrote for solidity: https://github.com/partylikeits1983/num_complex_solidity
Here's an example of finding the natural log of i.
contract model {
Num_Complex Complex;
Num_Complex.Complex a = Complex.wrap(0, 1e18);
function test() public returns (Num_Complex.Complex memory) {
Num_Complex.Complex memory result = Complex.ln(a);
return result;
}
}
However, currently there are some limitations to the library. Currently, complex numbers are handled in a struct as elementary user defined type and do not use the user defined type functionality that was added in Solidity version 0.8.8.
I was wondering if in the future it would be possible to define a custom type in solidity as struct instead of only the built in value types. Currently it is not possible to add two data types to a user defined type, which would be useful for complex numbers.
For example, it would be useful if it was possible to define a type as:
Struct Complex {
int re;
int im;
}
type complex is Complex;
To get around the added abstraction of using a struct to contain two ints, I thought of splitting a int256 into two int128 parts the first 128 bits being the real part and the last 128 bits the the imaginary part of a complex number, however, I believe this would increase complexity and introduce new bugs.
Would be grateful for feedback!
๐ Our 1st Community Call of 2023 is this week!
During the call, you'll have the opportunity to:
๐ป๏ธ Learn about operators for user defined value types.
๐ค Ask questions and give feedback to the Solidity Team
Join us Wednesday, February 1st at 15 CET
https://twitter.com/solidity_lang/status/1620093589568253954?s=20&t=fptYnlA9kTEZBFhhpuCEPQ
interface IRoyalties {
function getRoyalties(uint256 tokenId, uint256 tier) public view returns (uint256);
}
contract MyRoyalties is IRoyalties {
uint256 FIXED_ROYALTIES = 1000;
function getRoyalties(uint256 /* tokenId */, uint256 tier) public view returns (uint256) {
return FIXED_ROYALTIES * tier;
}
function useRoyalties() public {
uint256 royalties = getRoyalties({
????: 0, // <<-- This will not compile
tier: 2
});
// do something with royalties
}
}
We just released Solidity 0.8.18! ๐
This version includes the following notable features:
We have also included 11 bugfixes! ๐
๐ https://blog.soliditylang.org/2023/02/01/solidity-0.8.18-release-announcement/
๐พ https://github.com/ethereum/solidity/releases/tag/v0.8.18