Re: [fpc-pascal] assigning a local function to a var

2008-07-11 Thread David Emerson
On Friday 11 July 2008 5:36 am, Florian Klaempfl wrote: > David Emerson schrieb: > > Or is it just difficult to implement, and/or not considered useful? > > The procvar handling code is one of the ugliest parts of the > compiler :) Well, I would *clearly* be in well over my head, as I expected.

Re: [fpc-pascal] assigning a local function to a var

2008-07-11 Thread Florian Klaempfl
David Emerson schrieb: Or is it just difficult to implement, and/or not considered useful? The procvar handling code is one of the ugliest parts of the compiler :) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org

Re: [fpc-pascal] assigning a local function to a var

2008-07-11 Thread Jonas Maebe
On 10 Jul 2008, at 23:50, Lourival Mendes wrote: var // my_proc : procedure; // need to specify "local". impossible? my_proc : TProcedure; // Lourival begin what_to_say := 'hello, world!'; // Lourival Begin my_proc:= nil; if not Assigned(my_proc) then begin

Re: [fpc-pascal] assigning a local function to a var

2008-07-11 Thread Jonas Maebe
On 11 Jul 2008, at 00:09, Marco van de Voort wrote: Thus, I would ask of the devs, has this functionality been considered? Yes. A solution for this problem is needed for Mac Pascal compatability. No, it isn't. Mac Pascal only requires that you can declare a procedure like this: proce

Re: [fpc-pascal] assigning a local function to a var

2008-07-10 Thread Marco van de Voort
> Thus, I would ask of the devs, has this functionality been considered? Yes. A solution for this problem is needed for Mac Pascal compatability. > Is there some particular reason that anyone is opposed to implementing > it? Not really I guess. > Or is it just difficult to implement, and/or n

Re: [fpc-pascal] assigning a local function to a var

2008-07-10 Thread Lourival Mendes
Dear David, Sorry for my question, probably I didn't get the real idea of what you need, but I didn't see why the revised version didn't work. Actually, I would write it like: procedure test; var what_to_say : ansistring; procedure proc_a; begin writeln ('A says, "',

Re: [fpc-pascal] assigning a local function to a var

2008-07-10 Thread Joao Morais
David Emerson wrote: You're missing the point -- those functions, func_a and func_b, should be embedded within another function. The behavior I would like to see concerns local functions, not global functions. In your executable, func_a and func_b are global functions (within the unit) not loc

Re: [fpc-pascal] assigning a local function to a var

2008-07-10 Thread David Emerson
Hi Joao, You're missing the point -- those functions, func_a and func_b, should be embedded within another function. The behavior I would like to see concerns local functions, not global functions. In your executable, func_a and func_b are global functions (within the unit) not local function

Re: [fpc-pascal] assigning a local function to a var

2008-07-10 Thread Joao Morais
David Emerson wrote: Joao: creating a named type isn't a solution, as it only moves the problem of declaration into the "type" section, where the very same problem persists. Thanks for responding, though. Did you test? I did and it works. == function func_a(pass_str: ansistring): bool

Re: [fpc-pascal] assigning a local function to a var

2008-07-10 Thread David Emerson
Thanks Lourival, Joao, Chris, for your responses. It looks like what I'm attempting is not possible. FWIW, I've included a more illustrative example at the end of this message. Thus, I would ask of the devs, has this functionality been considered? Is there some particular reason that anyone is

[fpc-pascal] assigning a local function to a var

2008-07-09 Thread Chris Cheney
> I'd like to store an address of a local function in a variable, and > call that local function, but I don't know how to define a variable of > type "local function". Here's the error I'm stuck on, with sample > code: "One can assign the following values to a procedural type variable: 1. Nil, fo

Re: [fpc-pascal] assigning a local function to a var

2008-07-09 Thread Joao Morais
David Emerson wrote: var // what should this be?? my_func : function (pass_str : ansistring) : boolean; Declare a new type: type tmy_func = function(pass_str: ansistring): boolean; var my_func: tmy_func; Joao Morais ___ fpc-pasca

Re: [fpc-pascal] assigning a local function to a var

2008-07-09 Thread Lourival Mendes
I'm not sure, but you could use TProcedure, some think like this: procedure test; function func_a (pass_str : ansistring) : boolean; begin writeln (pass_str, 'A'); func_a := true; end; function func_b (pass_str : ansistring) : boolean; begin wri

[fpc-pascal] assigning a local function to a var

2008-07-09 Thread David Emerson
I'd like to store an address of a local function in a variable, and call that local function, but I don't know how to define a variable of type "local function". Here's the error I'm stuck on, with sample code: Error: Incompatible types: got "" expected "" procedure test; function func_a (