> Hi internals !
>
> I came into a problem when writing an IDL to PHP5 language mapping
> specification and an IDL to PHP5 language compiler. I'm using the
community
> OpenORB IDL-to-Java compiler as a base for writing the IDL-to-PHP5
compiler,
> in fact, it is a translation from Java to PHP5. Everything is ok except
the
> "finally" clause wich doesn't exists in Zend Engine 2. I know that many of
> you think that "finally" is useless but consider this case, and if anyone
> have a simple and elegant solution without implementing "finally" I'll be
> glad to listen.
> The code would be like this if we had finally:
> <?
> ...
> $_input = null;
> try {
> $_output = $this->_request('bind',true);
> org__omg__CosNaming__NameHelper::write($_output,$n );
> $_output->write_Object($obj);
> $_input = $this->_invoke($_output);
> return;
> } catch(org__omg__CORBA__portable__RemarshalExceptio n $_exception) {
> continue;
> } catch(org__omg__CORBA__portable__ApplicationExcept ion $_exception) {
> $_exception_id = $_exception->getId();
> if ($_exception_id ==
> org__omg__CosNaming__NamingContextPackage__NotFoun dHelper::id()) {
> throw
>
org__omg__CosNaming__NamingContextPackage__NotFoun dHelper::read($_exception-
> >getInputStream());
> }
> if ($_exception_id ==
> org__omg__CosNaming__NamingContextPackage__CannotP roceedHelper::id()) {
> throw
>
org__omg__CosNaming__NamingContextPackage__CannotP roceedHelper::read($_excep
> tion->getInputStream());
> }
> if ($_exception_id ==
> org__omg__CosNaming__NamingContextPackage__Invalid NameHelper::id()) {
> throw
>
org__omg__CosNaming__NamingContextPackage__Invalid NameHelper::read($_excepti
> on->getInputStream());
> }
> if ($_exception_id ==
> org__omg__CosNaming__NamingContextPackage__Already BoundHelper::id()) {
> throw
>
org__omg__CosNaming__NamingContextPackage__Already BoundHelper::read($_except
> ion->getInputStream());
> }
> throw new org__omg__CORBA__UNKNOWN("Unexpected User Exception:
> $_exception_id");
> } catch(Exception $_exception) {
> throw $_exception;
> } finally {
> $this->_releaseReply($_input);
> }
> ...
> ?>
>
> Since we don't have finally, the current code is:
>
> <?
> ...
> $_input = null;
> try {
> $_output = $this->_request('bind',true);
> org__omg__CosNaming__NameHelper::write($_output,$n );
> $_output->write_Object($obj);
> $_input = $this->_invoke($_output);
> $this->_releaseReply($_input); //PHP still does not have FINALLY
!!!
> return;
> } catch(org__omg__CORBA__portable__RemarshalExceptio n $_exception) {
> $this->_releaseReply($_input); //PHP still does not have FINALLY
!!!
> continue;
> } catch(org__omg__CORBA__portable__ApplicationExcept ion $_exception) {
> $_exception_id = $_exception->getId();
> if ($_exception_id ==
> org__omg__CosNaming__NamingContextPackage__NotFoun dHelper::id()) {
> $this->_releaseReply($_input); //PHP still does not have
FINALLY
> !!!
> throw
>
org__omg__CosNaming__NamingContextPackage__NotFoun dHelper::read($_exception-
> >getInputStream());
> }
> if ($_exception_id ==
> org__omg__CosNaming__NamingContextPackage__CannotP roceedHelper::id()) {
> $this->_releaseReply($_input); //PHP still does not have
FINALLY
> !!!
> throw
>
org__omg__CosNaming__NamingContextPackage__CannotP roceedHelper::read($_excep
> tion->getInputStream());
> }
> if ($_exception_id ==
> org__omg__CosNaming__NamingContextPackage__Invalid NameHelper::id()) {
> $this->_releaseReply($_input); //PHP still does not have
FINALLY
> !!!
> throw
>
org__omg__CosNaming__NamingContextPackage__Invalid NameHelper::read($_excepti
> on->getInputStream());
> }
> if ($_exception_id ==
> org__omg__CosNaming__NamingContextPackage__Already BoundHelper::id()) {
> $this->_releaseReply($_input); //PHP still does not have
FINALLY
> !!!
> throw
>
org__omg__CosNaming__NamingContextPackage__Already BoundHelper::read($_except
> ion->getInputStream());
> }
> $this->_releaseReply($_input); //PHP still does not have FINALLY
!!!
> throw new org__omg__CORBA__UNKNOWN("Unexpected User Exception:
> $_exception_id");
> } catch(Exception $_exception) {
> $this->_releaseReply($_input); //PHP still does not have FINALLY
!!!
> throw $_exception;
> }
> $this->_releaseReply($_input); //PHP still does not have FINALLY !!!
> ...
> ?>
>
> IMHO, I think that ting the finally code at the end of every catch
> block, before every throw/return statement and at the end of the try/catch
> statement justify the need of "finally".
> If there is another aproach without "finally" and without code redundancy,
I
> really need it.
>
Any ideas ?

Best Regards,

Cristiano Duarte

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]