# php suggestion

- Thread: https://externals.io/message/14915
- Original archive: https://news-web.php.net/php.internals/14915
- Started by Ante Drnasin on 2005-02-14T09:17:32+00:00
- Messages: 6
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #14915 — Ante Drnasin — 2005-02-14T09:17:32+00:00

URL: https://externals.io/message/14915#14915

Hi again guys....

I would just like to hear you oppinions about something like 
this...(please don't shoot me :) )

ex1:
function AddToDb(mysql_scape_string($text)) {
     //enter $text to db
}

which would be the same as

function AddToDb($text) {
     $text = mysql_escape_string($text);
     //enter $text to db
}

or

ex2:

function removeDigitsFromText($text) {
      //return the text striped from digits
}

function AddTextToDB(removeDigitsFromText($text)) {
	//add text to db;
}

This could be very usefull although I do understand that it could cause 
problems (references for example) ....


I know this concept looks a bit strange but just wanted to hear 
oppinions from the experts... :)

Thanx

Ante

---

## #14916 — David Kingma | jool.nl — 2005-02-14T09:20:01+00:00

URL: https://externals.io/message/14915#14916 · In reply to: #14915

Quoting Ante Drnasin <ante.dfg@moj.net>:
> ex1:
> function AddToDb(mysql_scape_string($text)) {
>      //enter $text to db
> }
> which would be the same as
> function AddToDb($text) {
>      $text = mysql_escape_string($text);
>      //enter $text to db
> }
> 
> ex2:
> 
> function removeDigitsFromText($text) {
>       //return the text striped from digits
> }
> 
> function AddTextToDB(removeDigitsFromText($text)) {
> 	//add text to db;
> }
> 
> This could be very usefull although I do understand that it could cause 
> problems (references for example) ....

Why could this be usefull? You're putting logic into the parameter list, I can't
think of a reason why you would like to do this.



----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

---

## #14924 — Nicholas Telford — 2005-02-14T11:17:34+00:00

URL: https://externals.io/message/14915#14924 · In reply to: #14916

David Kingma | jool.nl wrote:
> Quoting Ante Drnasin <ante.dfg@moj.net>:
> 
> > […]
> 
> 
> Why could this be usefull? You're putting logic into the parameter list, I can't
> think of a reason why you would like to do this.
> 
> 
> 
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.

This could never be useful. Trying to condense as much code as you can 
down to as few lines as possible doesn't actually speed up the 
execution, nor does it make it more readable.

Having logic in the parameter list removes the possibility of properly
documenting it and would be executed no quicker than having it done
separately.

If you're developing a public API as it seems you are, then the need for
proper documentation far outweighs the need to condense all the code
down, even for processes that are as obvious as escaping a string.

In short, there's no good reason for this to exist in any language (as
far as I can see) and would probably add more overhead to the processing
of parameter lists.

Nick

---

## #14917 — George Schlossnagle — 2005-02-14T15:21:57+00:00

URL: https://externals.io/message/14915#14917 · In reply to: #14915

>
> I know this concept looks a bit strange but just wanted to hear 
> oppinions from the experts... :)

This concept looks strange (and non-standard - do any other languages 
support this semantic?).  It doesn't save you much typing either.

George

---

## #14919 — Christian Schneider — 2005-02-14T16:29:16+00:00

URL: https://externals.io/message/14915#14919 · In reply to: #14915

Hey Ante,

Ante Drnasin wrote:
> I would just like to hear you oppinions about something like 
> this...(please don't shoot me :) )
> 
> ex1:
> function AddToDb(mysql_scape_string($text)) {

I'd say it's not too useful but opens up a can of worms:
- You're adding code to a declaration, IMHO confusing
- How complicated code is allowed, e.g. what happens with
   function foo(bar($p1, $p2)) {
   or
   function foo($p2->bar($p1), $p1->bar($p2)) {

I think we should keep the language simple and stay with
	$text = mysql_scape_string($text);
at the beginning of the function. That way everybody understands what's 
going on.

- Chris

---

## #14922 — Nicholas Telford — 2005-02-14T16:34:06+00:00

URL: https://externals.io/message/14915#14922 · In reply to: #14916

David Kingma | jool.nl wrote:
> Quoting Ante Drnasin <ante.dfg@moj.net>:
> 
> > […]
> 
> 
> Why could this be usefull? You're putting logic into the parameter list, I can't
> think of a reason why you would like to do this.
> 
> 
> 
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.

This could never be useful. Trying to condense as much code as you can 
down to as few lines as possible doesn't actually speed up the 
execution, nor does it make it more readable.

Having logic in the parameter list removes the possibility of properly
documenting it and would be executed no quicker than having it done
separately.

If you're developing a public API as it seems you are, then the need for
proper documentation far outweighs the need to condense all the code
down, even for processes that are as obvious as escaping a string.

In short, there's no good reason for this to exist in any language (as
far as I can see) and would probably add more overhead to the processing
of parameter lists.

Nicholas Telford
