Re: [SMARTY] defining arrays in config files

From: Date: Mon, 23 Feb 2004 21:45:46 +0000
Subject: Re: [SMARTY] defining arrays in config files
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-11013@lists.php.net to get a copy of this message
> (nice to read you again :) (thanks! Good to be back :) > > ago). Unfortunately, I haven't had time to check into the latest > > changes to config_load (config loading via resources in 2.6.2?) so > > I don't know if they are still appropriate. > > that change is really simple. the source of the (static) > config-file-contents can be any resource. but there is no big > relation to templates. no further processing of the fetched resource > -contents is done inside config_load(). Okay. I often thought it somewhat strange that the data acquiring/reading and the data parsing were handled by a single class; now that resources are introduced into config_load it seems even less appropriate to have the two combined, IMO. Also, IIR, config_load is fairly tightly bound to Config_File (without a proper instance reference and with virtually no context information exchanged) and further there is no reference back to $smarty from the instantiated config class. I'll see where you guys go with this before yapping about it again. Oh yeah, and I'll make a review of the code, too :) > > It looks like the current plan is that the new config format will > > be fully BC. > > not *fully*. the definition of a comment in a config-file is > "everything that is not a valid line is a comment". a bad definition > IMHO: every addition to config-file's syntax makes something been a > comment before become something else. but i think in the cases > discussed here this is only of academic interest, i don't think > anybody used "foo.bar = value" as a comment. Agreed. > > If that is not possible and BC must be broken, then I suggest > > a rethink and propose that syntax similar to YAML > > (http://yaml.org/spec/) be adopted. > > AFAIK yaml's goal is to be easily read and written by machines. in > contrast config-files should be maintained by humans. I'll try to stay on topic, but one of YAML's MAIN goals is to be easily readable (and producable) by humans (it is light on syntax). Many YAML documents look like "normal human" documents as opposed to machine readable instruction. True YAML has refined models for machine translation but that is natural since YAML does target serialization. Config files can of course be considered to be serialized data--indeed, that is Smarty's view of them. YAML is probably not appropriate at this juncture as syntax doesn't appear to be changing much, but it is worth considering for later adoption. If nothing else, it is worth reading the spec as the authors have covered the topic area very extensively and their ideas can be profitable when considering extensions to Smarty's config syntax, IMO. One thing to consider with the syntax is the indexes. Ought things like foo.bar[1] be acceptable or should array indexes be handled automatically? eg: foo.bar[] (explicit) or even foo.bar (results in foo.bar[] as in current implementation for multiple foo.bar entries) This would preserve for loops on indexed arrays since they would be gauranteed to be sequential and without gaps. I would also suggest to go against the PHP convenience of allowing the mixing of indexed arrays and hashes. One last idea I had to throw out there: leave the section item processing exactly as it is (no dot notation) and instead make the section names be the thing that determine the array name: [foo.bar] ... [foo.baz] ... I guess this should be on the dev list. Oh well. xo boots __________________________________ Do you Yahoo!? Yahoo! Mail SpamGuard - Read only the mail you want. http://antispam.yahoo.com/tools

« previous php.smarty.general (#11013) next »