Newbie questions about non-static, static and EXPORT

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Newbie questions about non-static, static and EXPORT

Mariano Martinez Peck
 
Hi folks, I am trying to understand them. What I understood so that is that from SLANG we can say:

<export: true>   ----> it will add the keyword EXPORT(sqInt) functXX();

<api>    ---->   it WONT put the static prefix  ->>    (sqInt) funcXXX()

if nothing is said    ->   it puts the static   ->>  static (sqInt)   functXXX()

If I understood correctly, static functions are not callable outside of the C file they are defined in. So, if you don't put static, then they are callable.

I am correct with all that ?

So..first question, why we need the this ?   when I should declare a function/method as API ? is it possible that this is when plugins need to call a function from the VM ?

Second, when should I need to declare a method/function as EXPORT ? Are there any other reason that being able to call them from GDB ?

Third, why there are methods which do not put the <export: true>    but in fact are added in #requiredMethodNames and hence exported.   Why they cannot have the <export: true>   instead of being hardcoded there?

Thanks a lot in advance,

--
Mariano
http://marianopeck.wordpress.com

Reply | Threaded
Open this post in threaded view
|

Re: Newbie questions about non-static, static and EXPORT

Igor Stasenko

On 13 April 2011 22:39, Mariano Martinez Peck <[hidden email]> wrote:

>
> Hi folks, I am trying to understand them. What I understood so that is that from SLANG we can say:
>
> <export: true>   ----> it will add the keyword EXPORT(sqInt) functXX();
>
> <api>    ---->   it WONT put the static prefix  ->>    (sqInt) funcXXX()
>
> if nothing is said    ->   it puts the static   ->>  static (sqInt)   functXXX()
>
> If I understood correctly, static functions are not callable outside of the C file they are defined in. So, if you don't put static, then they are callable.
>
> I am correct with all that ?
>
I think yes. But i'm not sure about <api> since it was introduced in
Cog and i haven't time to check what exactly it does.

> So..first question, why we need the this ?   when I should declare a function/method as API ? is it possible that this is when plugins need to call a function from the VM ?
>
> Second, when should I need to declare a method/function as EXPORT ? Are there any other reason that being able to call them from GDB ?
>
> Third, why there are methods which do not put the <export: true>    but in fact are added in #requiredMethodNames and hence exported.   Why they cannot have the <export: true>   instead of being hardcoded there?

to prevent them from being fully inlined and removed from source code
as a separate function.

>
> Thanks a lot in advance,
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
>
>



--
Best regards,
Igor Stasenko AKA sig.