IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New another solution
I have kicked around the idea of simulated named parameters using a string. Example:

href('Forums', 'z.iwethey.org', ''); // no extra params

href('Forums', 'z.iwethey.org', 'underline=no, target="_blank"');



Inside we could then have a standard function(s) that parses out the value:

function href($title, $url, $namedParams) {
....
$target = getParam($namedParams, 'target');
if (! empty($target)) {....}
....
} // end-func

However, the parsing may slow things down. But for typical intranets it may be fine.
________________
oop.ismad.com
Expand Edited by tablizer Aug. 16, 2003, 04:06:45 AM EDT
Expand Edited by tablizer Aug. 16, 2003, 04:08:51 AM EDT
New No, it's not.
In fact, it's slightly worse. The string parsing required would be a significant drawback; in ease-of-use, in efficiency and in concept. FWIW, the PHP equivalent in my approach to that would be:
href('Forums', 'z.iwethey.org', array('underline' => false, 'target' => "_blank");

Wade.

Is it enough to love
Is it enough to breathe
Somebody rip my heart out
And leave me here to bleed
 
Is it enough to die
Somebody save my life
I'd rather be Anything but Ordinary
Please

-- "Anything but Ordinary" by Avril Lavigne.

New That is more syntax
My approach is only 2 more characters than native named params. Yours is at least a dozen more. Slower? Yes, I agree. But it depends on the environment whether speed is the bottleneck or harder-to-read code.
________________
oop.ismad.com
New OT: Bryce...
Send me your information... I got the BOOK!
--
[link|mailto:greg@gregfolkert.net|greg],
[link|http://www.iwethey.org/ed_curry|REMEMBER ED CURRY!] @ iwethey

[insert witty saying here]
New OT: I don't have access to receipt. On biz travel
Okay with me to assume stamped postage value.
________________
oop.ismad.com
Expand Edited by tablizer Aug. 24, 2003, 02:06:08 PM EDT
New Also more limited
The string approach is also limited to literal values. Variables would have to be interpolated into the string (easy or not, depending on the language), but even then would only work with values that can be reliably converted to a string and back.
--
-- Jim Weirich jweirich@one.net [link|http://onestepback.org|http://onestepback.org]
---------------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
New There be XML
--

Less Is More. In my book, About Face, I introduce over 50 powerful design axioms. This is one of them.

--Alan Cooper. The Inmates Are Running the Asylum
New but XML "solves" the problem by not having variables
________________
oop.ismad.com
New minor issues IMO
The string approach is also limited to literal values. Variables would have to be interpolated into the string (easy or not, depending on the language)

PHP makes variable insertion easy. Example:

$bar = "glog";
foo($x, $y, $z, "myvar=$bar");

Of course, if you are passing something more complex than a variable, this may not be so easy. But, if you are passing an array, then a dedicated parameter is probably the way to go. Or, just pass SQL needed to retreive the info.

but even then would only work with values that can be reliably converted to a string and back.

Being that I tend to put complex structures in the database instead of code thingies, this is usually not a problem for me.
________________
oop.ismad.com
Expand Edited by tablizer Aug. 24, 2003, 02:15:27 PM EDT
New I should have known.
This is not actually for your benefit, Bryce, but it looks to me that you just didn't get my point about how I've implemented named parameters. I'm not surprised, really.

Wade.

P.S. Oh yeah: don't take this the wrong way! :-) It's just that by this point in a conversation, experience has taught me that if you haven't gotten the original point, it's a waste of time trying to get you to see it.

Is it enough to love
Is it enough to breathe
Somebody rip my heart out
And leave me here to bleed
 
Is it enough to die
Somebody save my life
I'd rather be Anything but Ordinary
Please

-- "Anything but Ordinary" by Avril Lavigne.

Expand Edited by static Aug. 25, 2003, 06:02:24 AM EDT
New Re: minor issues IMO
Jim: but even then would only work with values that can be reliably converted to a string and back.

Tablizer: Being that I tend to put complex structures in the database instead of code thingies, this is usually not a problem for me.

Things that cannot be converted to a string and back are usually the types of things that cannot be stored in a database. I'm thinking of open file connections, database connections, connection pools, procedure objects, semaphores, sockets, threads, mutexs, execution contexts, continuations, etc.

All of the above could easily be passed in an array or hash.
--
-- Jim Weirich jweirich@one.net [link|http://onestepback.org|http://onestepback.org]
---------------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
New difference in style
Things that cannot be converted to a string and back are usually the types of things that cannot be stored in a database. I'm thinking of open file connections, database connections, connection pools, procedure objects, semaphores, sockets, threads, mutexs, execution contexts, continuations, etc.

I suppose it depends on how the language works. In some langs/libs things like file connections and database connections were simply integers (ID's). The language kept a list (table?) of open "things". If there was a crash or shut-down, the list would be traversed and items closed.

I suppose in my ideal language and environment, EVERYTHING would be a table (surprise surprise). Thus, "complex structures" would be things like queries (strings) or ID's. Generally you reference the complex thing or service rather than pass it around as a RAM lump.

But tablisms aside, I don't generally find a need to put those kinds of things in named parameters for some reason. Named parameters are generally for "tweaks" rather than some complex structure by itself. I agree that arrays are more flexible, but like I said before, they are more wordy in calls. Given the tradeoffs, I would take less code. The few things that need complex RAM thingies down the road simply get a new fixed-position parameter, even if it requires finding and fixing existing calls. I doubt it would happen enough to justify more syntax. That is my weigh-in. Take it or leave it. (Assuming lack of real named params.)
________________
oop.ismad.com
     Positional parameters vs. Named parameters. - (static) - (30)
         Is it possible to ... - (jbrabeck)
         Not sure i'd use a dictionary - (ChrisR) - (5)
             That last suggestion... - (admin)
             Problem with overloading - (drewk)
             To be honest, I don't know. - (static)
             Python cookbook example + discussion: - (FuManChu) - (1)
                 Interesting. Some good ideas there. -NT - (static)
         A technique - (tuberculosis) - (4)
             That's pretty much what I'm trying to do. - (static) - (3)
                 Best Advice: Be merciless in your refactoring. - (tuberculosis) - (2)
                     Re: Best Advice: Be merciless in your refactoring. - (deSitter) - (1)
                         Its like cleaning house - (tuberculosis)
         May be you have a class trying to get born - (Arkadiy)
         Can't say without code - (JayMehaffey) - (2)
             Define 'better' :-) [+ some examples] - (static) - (1)
                 Re: Define 'better' :-) [+ some examples] - (JayMehaffey)
         another solution - (tablizer) - (11)
             No, it's not. - (static) - (10)
                 That is more syntax - (tablizer) - (9)
                     OT: Bryce... - (folkert) - (1)
                         OT: I don't have access to receipt. On biz travel - (tablizer)
                     Also more limited - (JimWeirich) - (6)
                         There be XML -NT - (Arkadiy) - (1)
                             but XML "solves" the problem by not having variables -NT - (tablizer)
                         minor issues IMO - (tablizer) - (3)
                             I should have known. - (static)
                             Re: minor issues IMO - (JimWeirich) - (1)
                                 difference in style - (tablizer)
         I generally lean towards the hash solution - (ben_tilly) - (1)
             That's a good idea. - (static)

And three Venezuelan llamas!
90 ms