On 2015-30-07 16:36, R.I.Pienaar wrote:
hello,

I've done a few little things with the type system and really like what it 
achieves,
was able to find a few bad data items in my hiera data and it saves on a lot of 
the
super annoying validation function calls.

The syntax though is pretty difficult to use, consider:

    define foo(
      Enum["present", "absent"] $ensure       = "present",
      Optional[String] $ssh_authorized_file   = undef,
      Optional[String] $email                 = undef,
      Optional[Integer] $uid                  = undef,
      Optional[Integer] $gid                  = undef,
      Variant[Boolean, String] $sudoer        = false,
      Boolean $setup_shell                    = false,
      Boolean $setup_rbenv                    = false
    ) {

So this has a few issues for me:

Reading it, I just don't see the property names now, its become a real effort
to read this.

    $ssh_authorized_file Optional[String] = undef,

seems better for this use case to me and this is probably going to be the most
often used use case.

This gets much worse when we involve more complex type definitions, I can't 
imagine
ever using a full on Struct definition here for example it would render it 
entirely
unreadable and be impossible to maintain

How would you ever fit this into a param declaration and maintain readability:

    Struct[{mode            => Enum[read, write, update],
            path            => Optional[String[1]],
            NotUndef[owner] => Optional[String[1]]}]

This leads to my 2nd question, I couldn't find a way to make my own abstract
types.

Consider this hypothetical with made up syntax and all:

    site.pp:
    typedef MyData Struct[{mode => Enum[read, write, update],
                           path            => Optional[String[1]],
                           NotUndef[owner] => Optional[String[1]]}]

    foo.pp:
    define foo(Mydata $data) {

this would improve matters a whole lot.  Does a typedef like feature exist? I 
couldn't
find anything and tried a few things but failed


The intent is to add typedef like this:

  type MyData = Struct[{ .... }]

Don't think we will change the order of type / param - too late to make that change, and would be different from most other languages where type declaration comes first.

- henrik



---
R.I.Pienaar



--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

--
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 puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/mpfu0c%24qph%241%40ger.gmane.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to