[Developers] quoting in par-file strings
Jonathan Thornburg
jthorn at aei.mpg.de
Sat Jun 4 05:26:09 CDT 2005
Hi,
>>> What is the advantage of having two different delimiters ?
>> It allows the following cases to avoid needing any explicit quoting:
>> Thorn::blah = "this isn't so bad"
>> Thorn::quux = 'I like "double quotes", do you?'
> Jonathan, didn't you also tell me that the second example isn't just
> hypothetic ? There seem to exist parfiles which already use single quotes
> (because Cactus didn't prevent this in the first place).
I thought so, but I wasn't quite sure, so I checked:
I searched all 2268 par files in the 645 thorns (some of them duplicates
due to symlinks or multiple versions) in my main cactus checkout.
I found no occurences of strings delimited by single quotes (').
I found 114 occurences of single quotes which weren't in comments.
Some yypical "use cases" from these include:
LSUDevelopment/HyperGR_MoL/par/brill.par
iobasic::outInfo_vars = "hypergr_mol::energy{reductions='sum'} "
AEIDevelopment/MultiPatchAdvectionToy/par/MPAT_test_6patch_FS.par"
GZPatchSystem::tag_angular_interpatch_interp_op[0] = "
default='Lagrange polynomial interpolation'
matter='ENO interpolation'
"
GZPatchSystem::tag_angular_interpatch_interp_pars[0] = "
default='order=5'
matter='order=4'
"
TAT/FFTW/par/wavetoyf77_rad_fftw.par
FFTW::gridfunctions = "wavetoy::phi[ft='fftw::ft[0]' power='fftw::power[0]']"
TAT/FFTW/par/wavetoyf77_rad_fftw_coarse_large.par
IOBasic::outScalar_vars = "wavetoy::phi fftw::ft[reductions='norm2']"
TAT/WaveToyFourierHelper/par/wavetoyf77_rad_fftw_coarse.par
IOBasic::outScalar_vars = "wavetoy::phi wavetoyfourierhelper::phi_ft[reductions='norm2']"
So, it seems that we could in fact get away with a simpler set of rules
for par files:
* strings are delimited by double quotes (")
* inside a string, \" gives a double-quote character, \\ gives a backslash
character, and \ followed by any other character gives a backslash
followed by that other character
This would allow all the cases I found by searching par files, and
would also allow the problem case I mentioned in my original E-mail,
where I wanted to assign the string
default='order=5' matter='order=2 limiter="Van Leer"'
to a Cactus string parameter:
MyThorn::MyPar = "default='order=5' matter='order=2 limiter=\"Van Leer\"'"
I have no objection to these simpler rules if people prefer them.
If we were to also adopt these rules for *.ccl files, then the following
param.ccl fragment (which I recently wrote in a physics thorn) would
also stay legal
keyword lapse_method "how should the lapse be determined?"
{
"Bona-Masso with K offset" :: \
"$\partial_t \alpha = -\alpha^2 f(\alpha) (K - K_0)$"
"Bona-Masso with shift divergence" :: \
"$\partial_t \alpha = -\alpha f(\alpha) (\alpha K - \del_i \beta^i)$"
} "Bona-Masso with shift divergence"
and would insert valid latex into the comment strings (where it might
be read by humans, or even (I think Steve has a patch-under-development
to do this) be automagically run through latex and nicely typeset.
(As noted previously, the fact that \p isn't valid inside a C string
is irrelevant here.)
ciao,
--
-- Jonathan Thornburg <jthorn at aei.mpg.de>
Max-Planck-Institut fuer Gravitationsphysik (Albert-Einstein-Institut),
Golm, Germany, "Old Europe" http://www.aei.mpg.de/~jthorn/home.html
"Washing one's hands of the conflict between the powerful and the
powerless means to side with the powerful, not to be neutral."
-- quote by Freire / poster by Oxfam
More information about the Developers
mailing list