Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
optional parameters of "component"
#18
mvlcek Wrote:And I don't like breaks, as they are basically a goto ;-)
We’ll let Chris decide over the multiple-returns or break usage then ;-)

mvlcek Wrote:As developer of components (with PHP code) I have to test the component (in debug mode) and will get error messages.
You still get error messages my way. Because the code is still eval()’d before I return anything. It’s just that the function will return FALSE if an error occurs, that way you can use it inside the template to offer an alternative when the component were to break.

mvlcek Wrote:And components returning values would add additional complexity, the user would have to look at the component to know what it returns and would not be able to do something as described above.
That’s something up to the “user” (as you call them) though. You might never want to use a return inside eval()’d code, I surely never want that, but someone might. It’s just a case I had to include in the check.

mvlcek Wrote:
Zegnåt Wrote:My proposed return is this: (Where $eval holds the return value of eval().)
Code:
$eval===NULL||$eval!==FALSE;

BTW: I think this will output a warning (at least in debug mode), if the component does not exist, as $eval is not set :-(

You are right, that’s my mistake, I will try to figure out what to do about that. The problem is that I can’t use isset(), because a working eval() will return NULL and isset(NULL)==FALSE.

I’m going to see what I can do.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply


Messages In This Thread
optional parameters of "component" - by bugman - 2011-06-08, 21:29:05
optional parameters of "component" - by bugman - 2011-06-08, 21:46:44
optional parameters of "component" - by mvlcek - 2011-06-08, 21:53:29
optional parameters of "component" - by bugman - 2011-06-08, 22:03:32
optional parameters of "component" - by bugman - 2011-06-08, 22:23:43
optional parameters of "component" - by mvlcek - 2011-06-18, 07:23:05
optional parameters of "component" - by mvlcek - 2011-06-18, 21:33:07
optional parameters of "component" - by ccagle8 - 2011-06-20, 09:10:54
optional parameters of "component" - by mvlcek - 2011-06-20, 16:27:53
optional parameters of "component" - by mvlcek - 2011-06-20, 19:36:30
optional parameters of "component" - by mvlcek - 2011-06-20, 20:45:03
optional parameters of "component" - by Zegnåt - 2011-06-20, 23:43:42
optional parameters of "component" - by mvlcek - 2011-06-20, 23:55:27
optional parameters of "component" - by mvlcek - 2011-06-21, 05:28:08



Users browsing this thread: 1 Guest(s)