Re: return value
Ger Hobbelt <[email protected]>
| Newsgroups | gmane.mail.spam.crm114 |
|---|---|
| Message-ID | <[email protected]> |
Definitely hitting a scope violation.
What happens here is that you are returning data to a unknown target
destination: after all, the 'call' command did not specify where the
return value should be stored, hence the return value is discarded.
Given the code and the (now inner-scope 'isolate (:user-feedback:)'),
that variable is unknown to the script interpreter in any outer scope.
Similar to other programming languages such as Pascal, C, etc.. In
pseudo code:
# global code
....
call procedureX(args) # no return value accepted
....
# localVar is an unknown variable around here...
...
...
procedure X(args)
{
declare localVar;
localVar := value;
return localVar; # return value ignored in crm114; would cause
compiler error in other (compiled) languages
}
In vanilla crm114, the declare LocalVar up there is really NOT local,
but _global_, so you can access that variable any time, any place
_after_ you've declared ('isolate') it.
Now that GerH crm114 support variable scoping, this behaviour only
works within the declaration scope.
--> declare it in global / outer scope, i.e. in the calling code,
before calling the procedure (this is the nasty way of coding this)
OR
pick up the return value by having 'call' pass a variable where the
returned value will be copied into (this is the advised way, not only
in the crm114 script language ;-) )
The crm114 script parser/P-code compiler isn't yet sophisticated
enough to warn about these things, say a la gcc prints errors for
similar mistakes in C/C++:
"error: variable LocalVar used at line 12345 but not declared in this
or any outer scope"
"warning: function return value is unused in call at line 12345: value
will be lost"
...
On Wed, Mar 25, 2009 at 10:12 AM, Paolo <[email protected]> wrote:
> On Wed, Mar 25, 2009 at 09:25:52AM +0100, Thomas Michael Hagen wrote:
>>
>> :interact: (:args:)
>> {
>> isolate (:user-feedback:)
>> input <byline> [stdin] (:user-feedback:)
>> return /:*:user-feedback:/
>> }
>>
>> as mentioned, the :user-feedback: variable does not get returned to
>> the caller; :read-pieces:.
>
> hm, perhaps you hit GerH's 'scoped vars' feature - try to move that ISOLATE
> at lower/lowest level (caller), then you'd RETRUN w/out args and check
> for that var in the caller. But looks like the problem is other, ie
> you're passing back just the value, not the var itself, so there might be
> something wrong with RETURN as well.
>
> --
> paolo
>
> ------------------------------------------------------------------------------
> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
> easily build your RIAs with Flex Builder, the Eclipse(TM)based development
> software that enables intelligent coding and step-through debugging.
> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
> _______________________________________________
> Crm114-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/crm114-general
>
--
Met vriendelijke groeten / Best regards,
Ger Hobbelt
--------------------------------------------------
web: http://www.hobbelt.com/
http://www.hebbut.net/
mail: [email protected]
mobile: +31-6-11 120 978
--------------------------------------------------
------------------------------------------------------------------------------