Re: [Gambas-user] Gambas has Gosub now!

2012-08-08 Thread Benoît Minisini
Le 05/08/2012 18:33, Emil Lenngren a écrit : > If there is a pending gosub + a catch, the gosub things on the stack are > erased, so when returning back, invalid values are copied from the stack. > > So at stack unwinding, the gosub slots must be kept. > > This crashes the interpreter now (or puts

Re: [Gambas-user] Gambas has Gosub now!

2012-08-05 Thread Emil Lenngren
If there is a pending gosub + a catch, the gosub things on the stack are erased, so when returning back, invalid values are copied from the stack. So at stack unwinding, the gosub slots must be kept. This crashes the interpreter now (or puts it in an infinite loop): Public Sub Main() Dim i As

Re: [Gambas-user] Gambas has Gosub now!

2012-07-22 Thread Benoît Minisini
Le 23/07/2012 01:14, Emil Lenngren a écrit : > It was this line I was worried about: > while (SP > (BP + FP->n_local + FP->n_ctrl)) > > /Emil > I think it's ok... Failing during a Gosub is not different from failing inside a deep expression evaluation. -- Benoît Minisini --

Re: [Gambas-user] Gambas has Gosub now!

2012-07-22 Thread Emil Lenngren
It was this line I was worried about: while (SP > (BP + FP->n_local + FP->n_ctrl)) /Emil 2012/7/23 Benoît Minisini > Le 23/07/2012 00:47, Emil Lenngren a écrit : > > Does exception handling with Catch work as I stated before? > > > > I am at a hotel in Vienna with Wi-Fi now so I can't test it r

Re: [Gambas-user] Gambas has Gosub now!

2012-07-22 Thread Benoît Minisini
Le 23/07/2012 00:47, Emil Lenngren a écrit : > Does exception handling with Catch work as I stated before? > > I am at a hotel in Vienna with Wi-Fi now so I can't test it right now :) > > /Emil > I didn't really test, but on the stack you have only: - Valid stack slot for control variables. - A

Re: [Gambas-user] Gambas has Gosub now!

2012-07-22 Thread Emil Lenngren
Does exception handling with Catch work as I stated before? I am at a hotel in Vienna with Wi-Fi now so I can't test it right now :) /Emil 2012/7/22 Benoît Minisini > Le 09/07/2012 00:46, Emil Lenngren a écrit : > > Just store it inside a T_POINTER? > > val->type = T_POINTER; > > val->_pointer

Re: [Gambas-user] Gambas has Gosub now!

2012-07-21 Thread Benoît Minisini
Le 09/07/2012 00:46, Emil Lenngren a écrit : > Just store it inside a T_POINTER? > val->type = T_POINTER; > val->_pointer.value = PC; > > Or whatever big enough datatype that doesn't do anything on RELEASE. > Your idea has been implemented in revision #4979! Regards, -- Benoît Minisini ---

Re: [Gambas-user] Gambas has Gosub now!

2012-07-08 Thread Emil Lenngren
Just store it inside a T_POINTER? val->type = T_POINTER; val->_pointer.value = PC; Or whatever big enough datatype that doesn't do anything on RELEASE. 2012/7/9 Benoît Minisini > Le 09/07/2012 00:13, Emil Lenngren a écrit : > > I have a little optimization idea: > > > > Instead of allocating a

Re: [Gambas-user] Gambas has Gosub now!

2012-07-08 Thread Benoît Minisini
Le 09/07/2012 00:13, Emil Lenngren a écrit : > I have a little optimization idea: > > Instead of allocating a new array EVERY time a gosub is called, instead use > the normal gambas stack. > First, let GP represent the offset 0 in &BP[fp->n_local + fp->n_ctrl]. > > At a gosub, run STACK_check(1 + f

Re: [Gambas-user] Gambas has Gosub now!

2012-07-08 Thread Emil Lenngren
I have a little optimization idea: Instead of allocating a new array EVERY time a gosub is called, instead use the normal gambas stack. First, let GP represent the offset 0 in &BP[fp->n_local + fp->n_ctrl]. At a gosub, run STACK_check(1 + fp->stack_usage - fp->n_local), then the return address an

Re: [Gambas-user] Gambas has Gosub now!

2012-03-06 Thread Kevin Fishburne
On 03/05/2012 09:00 PM, Benoît Minisini wrote: > Le 06/03/2012 02:11, Emil Lenngren a écrit : >> Yeah, if there is no stack relocation, I can assume that a lot of pointers >> into the stack will not change during other external calls, which should >> make code more optimized. >> >> Since local vari

Re: [Gambas-user] Gambas has Gosub now!

2012-03-05 Thread Benoît Minisini
Le 06/03/2012 02:11, Emil Lenngren a écrit : > Yeah, if there is no stack relocation, I can assume that a lot of pointers > into the stack will not change during other external calls, which should > make code more optimized. > > Since local variables and stack frames in gambas take up more space th

Re: [Gambas-user] Gambas has Gosub now!

2012-03-05 Thread Emil Lenngren
Yeah, if there is no stack relocation, I can assume that a lot of pointers into the stack will not change during other external calls, which should make code more optimized. Since local variables and stack frames in gambas take up more space than they do in C, I think the stack should be bit bigge

Re: [Gambas-user] Gambas has Gosub now!

2012-03-05 Thread Emil Lenngren
That code seems old and is not used I think. If it is used, it is not used correctly :) Because the stack can eat up all my memory if I do a lot of recursion. 2012/3/6 Benoît Minisini > Le 06/03/2012 02:00, Benoît Minisini a écrit : > > > > Maybe I should use getrlimit(RLIMIT_STACK, ...) to get

Re: [Gambas-user] Gambas has Gosub now!

2012-03-05 Thread Benoît Minisini
Le 06/03/2012 02:00, Benoît Minisini a écrit : > > Maybe I should use getrlimit(RLIMIT_STACK, ...) to get the maximum C > stack limit, and use it as the maximum Gambas stack limit too? > Hu... I'm already doing that... -- Benoît Minisini -

Re: [Gambas-user] Gambas has Gosub now!

2012-03-05 Thread Benoît Minisini
Le 05/03/2012 18:28, Emil Lenngren a écrit : > It is no strange at all that stack reallocation is slower and slower > as the recursion gets deeper. Because when the stack has to be > resized, a new memory area is allocated and the old stack is copied > over to the new, and the old gets freed. As t

Re: [Gambas-user] Gambas has Gosub now!

2012-03-05 Thread nando
Simple answer: yes Complex answer: yes -- Original Message --- From: Ru Vuott To: mailing list for gambas users Sent: Sun, 4 Mar 2012 15:23:24 + (GMT) Subject: Re: [Gambas-user] Gambas has Gosub now! > > But I get a compile error: > > error: 'TRANS_GO

Re: [Gambas-user] Gambas has Gosub now!

2012-03-05 Thread Emil Lenngren
It is no strange at all that stack reallocation is slower and slower as the recursion gets deeper. Because when the stack has to be resized, a new memory area is allocated and the old stack is copied over to the new, and the old gets freed. As the recursion gets deeper, more and more data has to be

Re: [Gambas-user] Gambas has Gosub now!

2012-03-04 Thread Benoît Minisini
Le 04/03/2012 10:16, Benoît Minisini a écrit : > Le 04/03/2012 02:23, Benoît Minisini a écrit : >> >> You are right, I didn't think about that. So the current design does not >> work, and I don't have another one. >> >> I will remove GOSUB if it cannot be implemented in a right way. :-/ >> >> Regar

Re: [Gambas-user] Gambas has Gosub now!

2012-03-04 Thread WALKER RICHARD
Why not try: RETURN label: It looks like a function return value but "label:" can only be a label, yes On 04/03/2012, Benoît Minisini wrote: > Le 04/03/2012 17:35, Jussi Lahtinen a écrit : >> Maybe there should be "GoBack" instead of "Return". >> We already have "GoTo" and "GoSub", so I think i

Re: [Gambas-user] Gambas has Gosub now!

2012-03-04 Thread Benoît Minisini
Le 04/03/2012 17:35, Jussi Lahtinen a écrit : > Maybe there should be "GoBack" instead of "Return". > We already have "GoTo" and "GoSub", so I think it would be logical... > > Jussi > Yes, but RETURN is the historical syntax in Basic. And I don't think it's a problem if you cannot return from the

Re: [Gambas-user] Gambas has Gosub now!

2012-03-04 Thread Benoît Minisini
Le 04/03/2012 15:23, Emil Lenngren a écrit : > Nice, to me it looks like that design works ;) > > But I get a compile error: > error: 'TRANS_GOTO' has no member named 'gosub' > > I assume the "share" folder was not commited to svn... > When I add "bool gosub" to the gbc_trans_common.h, it works. >

Re: [Gambas-user] Gambas has Gosub now!

2012-03-04 Thread Jussi Lahtinen
Maybe there should be "GoBack" instead of "Return". We already have "GoTo" and "GoSub", so I think it would be logical... Jussi 2012/3/4 Benoît Minisini > Le 04/03/2012 02:23, Benoît Minisini a écrit : > > > > You are right, I didn't think about that. So the current design does not > > work,

Re: [Gambas-user] Gambas has Gosub now!

2012-03-04 Thread Emil Lenngren
I think they can be useful. They both speed up the code and let you have "functions" inside functions that have access to all the local variables. /Emil 2012/3/4 Ru Vuott > > > But I get a compile error: > > error: 'TRANS_GOTO' has no member named 'gosub' > > I confirm this problem. > > > A que

Re: [Gambas-user] Gambas has Gosub now!

2012-03-04 Thread Ru Vuott
> But I get a compile error: > error: 'TRANS_GOTO' has no member named 'gosub' I confirm this problem. A question: Is this GOSUB really so "incredibly" useful ? Regards Vuott -- Virtualization & Cloud Management Using

Re: [Gambas-user] Gambas has Gosub now!

2012-03-04 Thread Emil Lenngren
Nice, to me it looks like that design works ;) But I get a compile error: error: 'TRANS_GOTO' has no member named 'gosub' I assume the "share" folder was not commited to svn... When I add "bool gosub" to the gbc_trans_common.h, it works. Now a little bug: Now the compiler thinks that all labels

Re: [Gambas-user] Gambas has Gosub now!

2012-03-04 Thread Benoît Minisini
Le 04/03/2012 02:23, Benoît Minisini a écrit : > > You are right, I didn't think about that. So the current design does not > work, and I don't have another one. > > I will remove GOSUB if it cannot be implemented in a right way. :-/ > > Regards, > Here is the only solution I found in revision #45

Re: [Gambas-user] Gambas has Gosub now!

2012-03-03 Thread nando
Superb work! Bravo! -- Original Message --- From: Benoît Minisini To: mailing list for gambas users Sent: Sun, 04 Mar 2012 02:23:57 +0100 Subject: Re: [Gambas-user] Gambas has Gosub now! > Le 04/03/2012 02:03, Emil Lenngren a écrit : > > Nice work! > > About

Re: [Gambas-user] Gambas has Gosub now!

2012-03-03 Thread Benoît Minisini
Le 04/03/2012 02:03, Emil Lenngren a écrit : > Nice work! > About "occupying" the Return keyword, why not simply use something like > "Return Gosub" indicating that you only want to return from the Gosub, and > not the whole function? > And as I said before, the code inside a gosub must somehow use

Re: [Gambas-user] Gambas has Gosub now!

2012-03-03 Thread Emil Lenngren
Nice work! About "occupying" the Return keyword, why not simply use something like "Return Gosub" indicating that you only want to return from the Gosub, and not the whole function? And as I said before, the code inside a gosub must somehow use control variables in a deeper depth or what you say, o

[Gambas-user] Gambas has Gosub now!

2012-03-03 Thread Benoît Minisini
Hi, I have just succeeded (I think) in implementing the old Basic GOSUB instruction in Gambas in revision #4530. I did that, because it is faster than using a plain little function, if you just need to call a small piece code without needing a specific context nor arguments. The syntax is the