Re: [PHP4BETA] Self-referencing variables revisited

From: Date: Tue, 28 Mar 2000 15:45:21 +0000
Subject: Re: [PHP4BETA] Self-referencing variables revisited
References: 1 2  Groups: php.version4 
Request: Send a blank email to php-version4+get-12746@lists.php.net to get a copy of this message
I don't find get_class_name() in the manual yet. Does it also support arrays and simple objects (not classes)? Another example: A generic function to create a database table, let's say receiving data from some other function or system. The the function wants input to be an array, the name of the array is the table name while the items in the array are the fieldnames. The alternative is to parse the data from the other system to determine the array name, which would probably be a more complex and resource intensive process, while the function must have a second argument, the name of the argument, to receive the results of the parsing. A contrived example (I really don't know what I'm doing here...) might be an input XML document, like: ... <foo>a</foo> <foo>b</foo> <foo>c</foo> ... which could be parsed into $foo[a], $foo[b],$foo[c]. But we don't know in advance what "foo" is. So we can't talk about $foo, only about its components. I just made this up so it's quite likely there are other ways to handle this particular example. I think I've demonstrated that such introspection is a useful tool, at least as useful as many other features in PHP; I'd like to see it in the 'list of things to do'. Its major utility will be generic libraries of classes and functions. I argue this feature is used commonly throughout the internals of PHP, but is not available to the PHP user. Since it is related to introspection, I suspect it would make the work of X (I forget his name) who is working on an Orbit module easier. But perhaps this is the reason _not_ to do it - it points to further expansion of PHP into a Java clone of sorts. I also can't speak to any security issues it may bring up for safe mode. Andrei Zmievski wrote: > On Mon, 27 Mar 2000, Gary Bickford wrote: > > 3. I just came up with this one, related to the last. If nameof() > > were a part of the language, then classes could have the ability to > > provide more useful error reporting, without explicit names in the > > code. Thus, one might have > > printf ("%s: Error %d - %s\n",nameof ($this), $this->errnum, > > $this->errstring) > > > > It appears to me that nameof() brings up the whole question of > > introspection... > > Use get_class_name($object). > > -Andrei > > "Music expresses that which can not be said > and on which it is impossible to be silent." > -Victor Hugo -- "Cyber is cyber, life is life." Gary E Bickford mailto:garyb@fxt.com FXT Corporation http://www.fxt.com/ tel:541-383-2749 mail:PO BOX 1808, SISTERS OR 97759 ship:66265 JERICHO ROAD, BEND OR 97701

« previous php.version4 (#12746) next »