PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > How to alias only one time, in an eval string.
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
How to alias only one time, in an eval string.

Réponse
 
LinkBack Outils de la discussion
Vieux 01/12/2007, 18h20   #1
trebor777
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut How to alias only one time, in an eval string.


I'm using a software which use compressed ruby scripts... For that, the
software load the uncompressed data and eval it.
In this software, you have the ability to reset the execution, and basically
it eval again all the uncompressed data.

The thing is... when you alias some methods from specific classes defined by
the software and not by the compressed scripts, it cause a stack error, as
aliased method are then on the second time refering to themselves:

alias b a
def a
do somethin
b
end

1st time ok,
but at the second time , a use b which refer to a which use b, etc.. etc..
I'm trying to check if the aliased method exist or not, but doesn't work for
a stange reason...

The main problem is I don't have any access to those Specific classes, or do
stuff before the eval.
I've tried to modify the alias method, but off course, it creates the same
problem but with this method.

any solution?


--
View this message in context: http://www.nabble.com/How-to-alias-o...html#a14108078
Sent from the ruby-talk mailing list archive at Nabble.com.


  Réponse avec citation
Vieux 01/12/2007, 18h56   #2
ara.t.howard
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to alias only one time, in an eval string.


On Dec 1, 2007, at 11:20 AM, trebor777 wrote:

> alias b a
> def a
> do somethin
> b
> end
>
> 1st time ok,
> but at the second time , a use b which refer to a which use b,
> etc.. etc..
> I'm trying to check if the aliased method exist or not, but doesn't
> work for
> a stange reason...
>
> The main problem is I don't have any access to those Specific
> classes, or do
> stuff before the eval.
> I've tried to modify the alias method, but off course, it creates
> the same
> problem but with this method.
>
> any solution?


wrapped =
begin
method 'b'
true
rescue NameError
false
end

eval code unless wrapped


a @ http://codeforpeople.com/
--
it is not enough to be compassionate. you must act.
h.h. the 14th dalai lama




  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 03h39.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10004 seconds with 10 queries