aslike: duck-typing with check interface

Oleg B code.viator at
Sat Jul 11 13:50:58 UTC 2020


I wrote library, that can be helpful in some cases:

1. easy and readable check interface of structures without 
'templatisation' of function or method
2. cache virtual methods table lookup for OOP implementations

1. define interface
2. use `Like` wrap as argument
3. wrap objects by `as` function


in cache example at my machine I have ~2 increase of performance:

$ ldc2 -O -I../../source/ app.d; and rm app.o; and ./app
delegates avg: [18 ms, 281 μs, and 7 hnsecs]
impliface avg: [36 ms, 70 μs, and 3 hnsecs]
likecache avg: [18 ms and 243 μs]


More information about the Digitalmars-d-announce mailing list