Hi Daniele,

many thanks for bringing up the Type style question.

On 10 Dec 2014, at 14:23, Daniele Sluijters <[email protected]> wrote:

> With the future parser we can now add type annotations to a whole bunch of 
> things. Usually it's pretty easy, just chuck the type in front of the 
> variable and you're done. But what if you have multiple variables or class 
> parameters beneath each other, do we align them, how do we align them, and 
> what about more complex type definitions?

> […]

> Should we break up complex type definitions:
> 
> class test (
>   String                           $param1,
>   String                           $param2,
>   Integer                          $param3,
>   Variant[String, Integer]         $param4 = 80,
>   Struct[{
>     a => Enum[hi, there, everyone]
>     b => Optional[Variant[
>                     Enum[yo, lo],
>                     Integer[2]]]
>   }]                               $param5 = { a => 'hi', },
> ) {}
> 
+1 for this example.
(I would prefer less whitespaces on the Optional part of the Struct.)

Do we have other examples available which would argue against a style like this 
one?


> I like this last one best. It limits the length of the line and by splitting 
> up the type definition according to the type we're defining (a hash) it 
> becomes fairly easy for a human to parse. But then, should the Variant after 
> the Optional be on a new line already or only the arguments to Variant since 
> that one can take multiples (like in the way you'd break up an array over 
> multiple lines) etc. etc. etc. I'm still not entirely happy about all the 
> white spacing between the type and the actual variable name but I do like the 
> columnar view it creates.
> 
> Eventually we'll be able to create/alias our own types which should limit the 
> amount of crazy before a variable or parameter definition but until then, 
> what do we do? And once we have the ability to create/alias our own types, 
> how do we style those?
> 
> We don't have to agree on a "it must be done exactly this anal way" but a 
> loose consensus about what it could look like would be useful.

ACK.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" 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/puppet-users/FB857CFA-7061-4782-BF65-448C57EC5901%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to