Re: [fpc-pascal] using functions from units & main programme

2011-11-20 Thread Sven Barth
On 19.11.2011 17:19, John Lee wrote: Surprised this capability hasn't come up before because doesn't sound technically difficult to do. Free Pascal is a static language, as Bernd already wrote and as such the compiler is geared towards this fact. So what you suggest would mean to rewrite larg

Re: [fpc-pascal] using functions from units & main programme

2011-11-19 Thread Bernd
2011/11/19 John Lee : > Surprised this capability hasn't come up before because doesn't > sound technically difficult to do. The problem is simply that at the time of compiling the unit all the function calls within it are already statically resolved and everything is cast in concrete. Pascal is a

Re: [fpc-pascal] using functions from units & main programme

2011-11-19 Thread Rich Saunders
On 11/19/11 11:19 AM, John Lee wrote: > Surprised this capability hasn't come up before because doesn't sound > technically difficult to do. The need for this capability HAS come up before. That's why the methods that are available are available. They may appear to be "too complicated" but it

Re: [fpc-pascal] using functions from units & main programme

2011-11-19 Thread John Lee
Thanks for the feedback & suggestions - looks like either functions as parameters or using objects are only ways to do this - either makes the code look horrible & more complex that necessary imo cf the normal use of functions. Surprised this capability hasn't come up before because doesn't sound t

Re: [fpc-pascal] using functions from units & main programme

2011-11-18 Thread Bart
On 11/18/11, Sven Barth wrote: > But he wants to call "fnb" in the main program and have that call "fna" > of the main program instead of "fna" from "jim". You're right. I misread the original post. Bart ___ fpc-pascal maillist - fpc-pascal@lists.fr

Re: [fpc-pascal] using functions from units & main programme

2011-11-18 Thread Bernd
2011/11/18 John Lee : > Never seen this before - is there a way I can force fnb to use the main > program's version of fna, not the version that's in the unit? > TIA John Your problem sounds very much like you would really want to make use of objects, inheritance and virtual methods. Instead of pa

Re: [fpc-pascal] using functions from units & main programme

2011-11-18 Thread Sven Barth
On 18.11.2011 18:15, Bart wrote: {file: prog.pas} Program Prog; {$ifdef fpc} {$mode objfpc}{h+} {$endif} uses jim; function fna: string; begin fna := 'Prog'; end; begin writeln('fna = ',fna); writeln('jim.fna = ,'jim.fna); end. Compiled with both TurboPascal 6.0 and fpc 2.4.4. the

Re: [fpc-pascal] using functions from units & main programme

2011-11-18 Thread Alberto Narduzzi
Thanks for the fix, but it makes the code a bit more complicated than I'd hoped/thought based on my (over simple?) impression that local fns are used in place of those in units. John this would be true if you declared another function fnb locally, so that calling fnb could eventually override t

Re: [fpc-pascal] using functions from units & main programme

2011-11-18 Thread Bart
{file: jim.pas} unit jim; {$ifdef fpc} {$mode objfpc}{h+} {$endif} interface function fna: string; function fnb: string; implementation function fna: string; begin fna := 'jim'; end; function fnb: string; begin fnb := fna; end; end. {file: prog.pas} Program Prog; {$ifdef fpc} {$mod

Re: [fpc-pascal] using functions from units & main programme

2011-11-18 Thread John Lee
Thanks for the fix, but it makes the code a bit more complicated than I'd hoped/thought based on my (over simple?) impression that local fns are used in place of those in units. John On 18 November 2011 16:55, Sven Barth wrote: > Am 18.11.2011 17:47, schrieb John Lee: > > Sorry for confusion, m

Re: [fpc-pascal] using functions from units & main programme

2011-11-18 Thread Sven Barth
Am 18.11.2011 17:47, schrieb John Lee: Sorry for confusion, my email wasn't clear... old fpc version, that I have to use because of availability of various units...Free Pascal Compiler version 2.2.2 [2008/08/03] for i386 this is jim.pp--- unit jim; interface function fna:string; function fnb

Re: [fpc-pascal] using functions from units & main programme

2011-11-18 Thread John Lee
Sorry for confusion, my email wasn't clear... old fpc version, that I have to use because of availability of various units...Free Pascal Compiler version 2.2.2 [2008/08/03] for i386 this is jim.pp--- unit jim; interface function fna:string; function fnb:string; implementation function fna:strin

Re: [fpc-pascal] using functions from units & main programme

2011-11-18 Thread Sven Barth
Am 18.11.2011 16:49, schrieb John Lee: I have a normal fpc unit, call it jim, with 2 functions fna & fnb . fnb uses internally fna. My main program, has a uses clause including jim, and also a _different_ version of fna, with same parameters as for that in jim, but no fnb. The problem I get is

Re: [fpc-pascal] using functions from units & main programme

2011-11-18 Thread Sven Barth
Am 18.11.2011 16:49, schrieb John Lee: I have a normal fpc unit, call it jim, with 2 functions fna & fnb . fnb uses internally fna. My main program, has a uses clause including jim, and also a _different_ version of fna, with same parameters as for that in jim, but no fnb. The problem I get is