[augeas-devel] [PATCH] add match construct to lens language
Dominique Dumont
domi.dumont at free.fr
Sat Feb 21 09:47:57 UTC 2009
David Lutterkort <lutter at redhat.com> writes:
> The default branch '| _ -> ...' is mandatory and must be the last
> one in the match statement (I don't want to deal with none of the
> branches matching at runtime)
Any reason why the default branch is associated with '_' ?
I mean the default branch could be written like:
| default -> '...'
or
| any -> '...'
or
| * -> '...'
IMHO, the switch-case statement would be more easy to grasp without
reading the whole lens doc...
> To make this more concrete, assuming that Sys.os_distro returns the name of
> the distro and Sys.os_vendor some sort of vendor namein some canonical
> form, we could write something like
>
> let grub_file_name = match Sys.os_vendor with
> | "Red Hat" -> "/etc/grub.conf"
> | _ -> (match Sys.os_distro with
> | "Debian" -> "/boot/grub/menu.lst"
> | "Ubuntu" -> "/boot/grub/menu.lst"
> | "FreeBSD" -> "/some/where/else"
> | _ -> "/nowhere/at/all")
> let xfm = transform Grub.lns (incl grub_file_name)
Eh, this looks like the warping mechanism [1] provided in
Config::Model :-)
> The one incompatibility is that 'match' and 'with' are now keywords
> - but the only place where they were used as identifiers was the
> Sshd lens, and easily fixed.
ok. There's no external impact on users.
All the best
[1] http://search.cpan.org/dist/Config-Model/lib/Config/Model/WarpedThing.pm#Warper_and_warped
More information about the augeas-devel
mailing list