I've been trying to think of something that would be a good project to cut
my teeth on for a first C project in forever and I'd rather work on
something that might be useful. While cleaning tabbing on a var_export for
a test class I think I have an idea.
What I'm looking for is two things. One, is this the sort of thing that a
beginner to C (not a beginning programmer mind you - I've been doing PHP
scripting for, gosh, 7 years now) can do. If so I'll do this just for the
experience of it because I need to learn how to prep patches and the
remainder of the process for more major patches - such as the include style
I RFC'ed earlier. It looks like if it's going to happen I'll have to learn
how to do it.
Anyway, var_export takes 2 arguments - the expression to be converted and
whether to return or echo it. I'd like to add a third, whether to use
spaces (default) or tabs for indentation
For backwards compatibility null would mean uses spaces, and use 2 per
indentation. If set to true a tab character would be used.
Thoughts and input appreciated.
If you're looking into doing something that are both useful and good for
learning C, my suggestion is to hack PHP in some way that makes something
possible (in PHP) that you couldn't simply accomplish by writing a simple
wrapper function or workaround. Making var_export use tabs instead of spaces
is easily accomplished by wrapping it in another function that preg_replaces
starting line spaces with tabs.
Reading your suggestion, I almost get the feeling that you believe the only
reason var_dump doesn't have more arguments (or does this yet) is because
nobody thought about it or had time changing it. Changing built in php
functions is not A Good Thing™ in general. Functions should serve a specific
purpose, not have a gazillion arbitrary arguments for every possible use
case.
For just the purpose of just learning C however, go ahead. Sounds like a
good start.
Hannes
I've been trying to think of something that would be a good project to cut
my teeth on for a first C project in forever and I'd rather work on
something that might be useful. While cleaning tabbing on a var_export for
a test class I think I have an idea.What I'm looking for is two things. One, is this the sort of thing that a
beginner to C (not a beginning programmer mind you - I've been doing PHP
scripting for, gosh, 7 years now) can do. If so I'll do this just for the
experience of it because I need to learn how to prep patches and the
remainder of the process for more major patches - such as the include style
I RFC'ed earlier. It looks like if it's going to happen I'll have to learn
how to do it.Anyway, var_export takes 2 arguments - the expression to be converted and
whether to return or echo it. I'd like to add a third, whether to use
spaces (default) or tabs for indentationFor backwards compatibility null would mean uses spaces, and use 2 per
indentation. If set to true a tab character would be used.Thoughts and input appreciated.
That is the primary purpose. For most datasets str_replace(' ', "\t",
var_export($obj, true)) gets what I want. But this is for exploration of
process. I don't expect it to be committed to the language on a permanent
basis. To be honest, it would be better as a php.ini setting -
export_indentation. The default value would be ' ' and PHP would fall to
that value if it isn't set.
And I'll likely do that as a step two learning thing.
Changing how includes work was my first suggestion and what I'd like to work
on, but that has to come after more elementary things.
On Mon, Jan 24, 2011 at 2:13 PM, Hannes Landeholm landeholm@gmail.comwrote:
If you're looking into doing something that are both useful and good for
learning C, my suggestion is to hack PHP in some way that makes something
possible (in PHP) that you couldn't simply accomplish by writing a simple
wrapper function or workaround. Making var_export use tabs instead of
spaces
is easily accomplished by wrapping it in another function that
preg_replaces
starting line spaces with tabs.Reading your suggestion, I almost get the feeling that you believe the only
reason var_dump doesn't have more arguments (or does this yet) is because
nobody thought about it or had time changing it. Changing built in php
functions is not A Good Thing™ in general. Functions should serve a
specific
purpose, not have a gazillion arbitrary arguments for every possible use
case.For just the purpose of just learning C however, go ahead. Sounds like a
good start.Hannes
I've been trying to think of something that would be a good project to
cut
my teeth on for a first C project in forever and I'd rather work on
something that might be useful. While cleaning tabbing on a var_export
for
a test class I think I have an idea.What I'm looking for is two things. One, is this the sort of thing that a
beginner to C (not a beginning programmer mind you - I've been doing PHP
scripting for, gosh, 7 years now) can do. If so I'll do this just for
the
experience of it because I need to learn how to prep patches and the
remainder of the process for more major patches - such as the include
style
I RFC'ed earlier. It looks like if it's going to happen I'll have to
learn
how to do it.Anyway, var_export takes 2 arguments - the expression to be converted and
whether to return or echo it. I'd like to add a third, whether to use
spaces (default) or tabs for indentationFor backwards compatibility null would mean uses spaces, and use 2 per
indentation. If set to true a tab character would be used.Thoughts and input appreciated.
Hi,
Anyway, var_export takes 2 arguments - the expression to be converted and
whether to return or echo it. I'd like to add a third, whether to use
spaces (default) or tabs for indentation
While I'm not sure that's really needed:
Why not a string parameter - then one could choose between 2 or 4 spaces
and tabs.
As var_Export is using smart_str this should be quite simple change to
do :-)
For backwards compatibility null would mean uses spaces, and use 2 per
indentation. If set to true a tab character would be used.
For BC the the key point is if it is omitted, since not passing a
parameter is different from passing NULL
(or any other value)
johannes