[fpc-devel] va(r)_arg vs open array
Bisma Jayadi
bisma at brawijaya.ac.id
Thu Oct 5 05:35:33 CEST 2006
> For example:
>
> %d/%d/%d (dd/mm/yyyy)
>
> Hello %s(Mr). %s (Van Der Voot),
>
> Thank you for interesting in our %s(product).
> %s (Marco) we are more then happy to help you and give you additional
> information about %s (product).
>
> You can either call us at the phone number of 1234567890 extension %d
> (10000) for customer support.
>
> You can also contact our sails department at phone number 1234567890
> extension %d (666) for upgrading your %s (product), or just to ask
> additional questions.
>
> You can also contact our support team at the email of %s at company.com
> (support/product name).
>
> Regards,
>
> Abraham Lincolen,
> Late US president.
If this is really the case that cause you demand var_args feature, then
obviously you have problem with your software design. I agree with Marco. :) I
wrote a program to solve a problem exactly like this without need of var_args
feature. Even though var_args is provided, I won't use it either, since -IMO-
var_args isn't the correct way to solve this kind of problem.
The above problem can be solved easily with a simple "find-and-replace"-like
algorithm. IMO, basically this is a template filling. Just put a unique tags
on every place that need to be filled with a value. Parse the template and
replace every tag with appropriate value and format. Likely this must be done
by a specialized class for this purpose.
With this solution, my program can do the job very well with more than 200
kind of tags on more than 20 kind of templates (and increasing by the day).
The users can even build their own template(s) through a template builder
wizard from my application. I believe the wizard can't be easily build just
using var_args. Your sample above, using my solution will become a template
like this (less or more):
> For example:
>
> <DATE:TODAY>
>
> Hello <CUSTOMER:TITLE>. <CUSTOMER:LAST_NAME>,
>
> Thank you for interesting in our <PRODUCT:NAME>.
> <CUSTOMER:FIRST_NAME> we are more then happy to help you and give you
> additional information about <PRODUCT:NAME>.
>
> You can either call us at the phone number of 1234567890 extension
> <PHONE_EXT:CUSTOMER_SUPPORT> for customer support.
>
> You can also contact our sails department at phone number 1234567890
> extension <PHONE_EXT:PRODUCT_UPGRADE> for upgrading your <PRODUCT:NAME>,
> or just to ask additional questions.
>
> You can also contact our support team at the email of <PRODUCT:EMAIL>.
>
> Regards,
>
> <DIRECTOR:FULL_NAME>,
> <JOB_TITLE:DIRECTOR>.
Or am I missing something here?
-Bee-
has Bee.ography at:
http://beeography.wordpress.com
More information about the fpc-devel
mailing list