[slang-users] debug: points where left on the stack

Joerg Sommer joerg at alea.gnuu.de
Tue Aug 23 06:12:14 EDT 2005


Marko Mahnic <marko.mahnic at email.si> wrote:
> Joerg Sommer wrote:
>> "John E. Davis" <davis at space.mit.edu> wrote:
>> 
>>>Joerg Sommer <joerg at alea.gnuu.de> wrote:
>>>
>>>>do_check();
>>>>do_something();
>>>>if ( () )
>>>
>>>You should try to minimize the use of such constructs.
>> 
>> Why? Is a cool feature of slang.
>> 
> It is a cool feature but it makes the code harder to read,
> understand

ACK

> and mantain.

You need more documentation and it is not readable for a non-slang
programmer. But something like this, too:

define vinsert ()
{
   _NARGS-1; Sprintf; insert;
}

I don't think this is problem, because every programming language has its
peculiarities and you can't read it if you don't know the language.

> One way to control the stack would be to use sth similar
> to _auto_declare (or _boseos_info).
> If the compilation unit would for example declare
>    _strict_return = 1

slsh> message(_slang_version_string);
2.0.4
slsh> message(_strict_return);
_strict_return is undefined
<stdin>:2:<top-level>:Undefined Name

> then all functions that leave sth on the stack would have
> to push the result on the stack with return.

Yes. This is exactly what I am searching for.

> Such byte-compiled functions would look like this
>     A = stack_pointer
>     .... compiled body ....
>     if (stack_pointer - A != _NRESULTS) do_error(...)

This can be done with slang? Is it possible for an eos handler to get
the number of arguments of return?

> In some cases one would need to return a different number of
> values even when _strict_return = 1. This could be done by
> setting _NRESULTS inside the function:
>
> define foo()
> {
>     _NRESULTS = 2;
>     push("abcde");
>     ....
>     return 5;

Why not use return("abcde", 5)?

Bye, Jörg.
-- 
Professor: "Gott", unverständliches und mythisches Wesen, das sich einmal
  pro Woche im Kreis der Sterblichen manifestiert um Weisheit auf Folien
  unter das Volk zu bringen.		(Dschungelbuch 11, FSU Jena)




More information about the slang-users-l mailing list