|
Posted by farrishj@gmail.com on 05/27/07 04:07
On May 26, 5:50 pm, gosha bine <stereof...@gmail.com> wrote:
> semi_e...@inbox.com wrote:
> > I am convinced there are good reasons to use strtok, maybe some folks
> > here can point me to a 'textbook situation' where strtok saves the day
> > or copy/paste a good self-explanatory example or link to additional
> > strtok() reading material.
>
> strtok and other strxxx functions from C's standard library have the
> advantage of speed and smaller memory footprint. For example if you have
> a comma-separated list of 1000 elements,
>
> $first = strtok($list, ',')
>
> is apparently much better than
>
> list($first) = explode(',', $list);
>
> Of course, in most real life situations such optimizations are not worth
> the trouble, finally it's only a scripting language... but strtok and
> friends are a good option for those who want fastest possible code.
Is this a shortcut of sorts to memory reference pointers? It feels a
little bit like a string_map function. Scripters have a hard time
molding that problem.
I think it's interesting that in some of the newer languages, the
simplest constructs are abstract ideas that similarly describe the
most systemically atomic memberships: generics, collections, objects.
Scripting is built around flexibility, so everything is everything;
ie, in JavaScript, everything is a generically collectionable object
(consider closures and anonymous functions); once you figure out how
to build classes and constructors, it's like gravy. C#, php, java,
python, etc...
"Simplicity" points at something different in strong-typed languages
than it does in soft-typed interpreted languages.
Navigation:
[Reply to this message]
|