Zulip Chat Archive
Stream: mathlib4
Topic: Meaning of `specialize`
Eric Wieser (Jan 18 2023 at 09:39):
Yaël Dillies said:
Is that a problem? We already have docs4#Nat.repeat
Tangential, but: what does @[specialize #[]]
mean there?
Mario Carneiro (Jan 18 2023 at 09:40):
looks like a doc-gen bug
Mario Carneiro (Jan 18 2023 at 09:40):
the source only has @[specialize]
Notification Bot (Jan 18 2023 at 09:42):
A message was moved here from #mathlib4 > Data.Fin.Tuple.Basic mathlib4#1516 by Eric Wieser.
Eric Wieser (Jan 18 2023 at 09:42):
Ugh, the mobile app doesn't move replies too, sorry @Mario Carneiro
Eric Wieser (Jan 18 2023 at 09:43):
Mario Carneiro said:
the source only has
@[specialize]
And what does that mean?
Mario Carneiro (Jan 18 2023 at 09:44):
if you are asking about what the @[specialize]
attribute itself does, it is an instruction to the compiler to prefer to specialize this declaration for different functions passed to it, similar to what monomorphization gives you in languages like C++/Rust
Mario Carneiro (Jan 18 2023 at 09:44):
lean already does this by default for arguments passed in typeclasses
Mario Carneiro (Jan 18 2023 at 09:45):
the library-writer's advice is to put this attribute on functions that take an explicit higher order (function) argument which would benefit from monomorphization
Last updated: Dec 20 2023 at 11:08 UTC