What is :-) ?
Antonio
antoniocabreraperez at gmail.com
Mon Nov 20 09:44:32 UTC 2023
On Monday, 20 November 2023 at 09:11:07 UTC, evilrat wrote:
> if you meant to take the function/delegate and not invoke try
> `&Counter` instead, otherwise it expects the parameters.
If you execute
```
writeln( "'Counter' is ", &Counter );
```
It shows the Counter address:
```
'Counter' is 557F2567F940
```
Not the function signature like it does with ```next```
I propose a simple change:
```d
void main(){
auto Counter = (int nextValue) => () => nextValue++;
auto next = Counter(10);
writeln( "'next' is ", next );
writeln( "'Counter' is ", Counter );
}
```
first ```writeln``` shows the signature of next:
```
'next' is int delegate() pure nothrow @nogc @safe
```
second writeln shows the address of Counter
```
'Counter' is 55568953C910
```
- Why writeln doesn't treat ```next``` and ```Counter``` the same
way? (I think I understand why, but it shows a "low" level
difference of something that syntactically is equivalent)
- What is the way to show Counter signature using ```writeln```
(if possible)?
```
More information about the Digitalmars-d-learn
mailing list