I don't think there's much gain in fiddling with Elixir internals trying to 
modify special form, or writing new macro specifically to omit the left 
argument in `::/2` for function specs. Perhaps more profoundly, this would 
implicitly tie one spec to one function clause, which is kinda odd if you want 
to specify typespecs for all clauses before a function head.

-------- Original Message --------
On 2 Jun 2022, 17:16, Boris Kuznetsov wrote:

> Currently, if you want to add spec to functions, you have to use @spec with a 
> function name to define all argument / response types:
>
> defmodule StringHelpers do
> @spec long_word?(word()) :: boolean()
> def long_word?(word) when is_binary(word) do
> String.length(word) > 8
> end
> end
>
> I think, it would be nice to reduce "visual noise" of spec definition by 
> allowing to omit the data we already know.
>
> defmodule StringHelpers do
> @spec word() :: boolean()
> def long_word?(word) when is_binary(word) do
> String.length(word) > 8
> end
> end
>
> With this syntax, we can define argument and response types and automatically 
> treat it as spec for following long_word?/1 function.
>
> What do you think?
>
> Also, in case of multiple arguments we can either wrap it in parentheses or 
> just use a comma for separation.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "elixir-lang-core" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> [https://groups.google.com/d/msgid/elixir-lang-core/01071A82-653F-488B-B17A-8C0858418C0C%40achempion.com](https://groups.google.com/d/msgid/elixir-lang-core/01071A82-653F-488B-B17A-8C0858418C0C%40achempion.com?utm_medium=email&utm_source=footer).

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/KdzCeocLwLic1hzdFgkdlFu81g75g7B1KdhmjV3Cas2AlMNFlYFI84C1Ass7kpFyBcTonhUaIuje-mcuthceO73tyZTbHdvqjSzCLyJvky8%3D%40pm.me.

Reply via email to