[Mono-list] Mapping PHP and Mono

Paolo Molaro lupus@ximian.com
Mon, 3 Feb 2003 11:30:11 +0100

On 02/01/03 Sterling Hughes wrote:
> 1) Property accesses are handled as overloaded methods.  If you prefix a
> method with "get", a property access is assumed.  So
> $obj = new mono("mystupidtest.test1");
> $obj->getTestVariable(); // <- This will perform a property access on
> TestVariable
> The same applies to setting properties:
> $obj->setTestVariable("Some Value");
> 2) Field accesses are equivalent to property accesses.  Meaning you can
> do:
> $obj = new mono("mystupidtest.test1");
> $obj->testField = 10;
> And it will be automagically set/getted.
> Does this design seem like a good thing?

It depends on the language. In C# property access looks like a fields
access even if under the hood it's a method call. So, what the
syntax looks like in php depends on how naturally the property access maps
to field access or to a method call for php programmers.

> Second, Are there anythings to consider when mapping objects to base
> types?  Ie, mapping a mono integer (which is an object) to a PHP

In the CLR there are many different integer types, int, byte, sbyte,
uint, long. They are not objects, though they can be boxed into objects.

> integer.  Does anyone have opinions as to whether these should be
> directly mapped (faster) or if everything, including base types should
> be objects, and then set's and get's would be overloaded (maps to the ms
> way, but is slow as all hell).  Are there anythings to consider so the
> performance degradation would be worthwhile?

Consider that if the accessor is a simple field load and it's not virtual, 
the jit will inline the method.
Using the bare integers of having a PHPInt object that encapsulates the
value depends a lot on what 'method' calls are possible on a php integer
variable or if the same variable can hold an integer and/or a string
like in perl and how much work you want to do in the mapping:-)


lupus@debian.org                                     debian/rules
lupus@ximian.com                             Monkeys do it better