Recent

Author Topic: Verify existence of a variable  (Read 1624 times)

MarkMLl

  • Hero Member
  • *****
  • Posts: 2700
Re: Verify existence of a variable
« Reply #15 on: April 21, 2021, 10:11:51 am »
Observations without intending to be critical: playing around, I notice that if I have a unit called Python this fails:

Code: Pascal  [Select][+][-]
  1. {$if declared(LoadVarargsRoutine) }
  2.   Python.LoadVarargsRoutine('*', true); (* Try to load all varargs routines     *)
  3. {$endif }
  4.  

PythonDemo.lpr(86,5) Error: Evaluating a conditional compiling expression

while this is successful:

Code: Pascal  [Select][+][-]
  1. {$if declared(LoadVarargsRoutine) }
  2.   Python.LoadVarargsRoutine('*', true); (* Try to load all varargs routines     *)
  3. {$endif }
  4.  

If instead of being a unit Python is an instance of class TPython (contained in unit python_dynamic which has been appropriately imported) then neither of these forms works:

Code: Pascal  [Select][+][-]
  1. {$if declared(TPython.LoadVarargsRoutine) }
  2. ...
  3. {$if declared(Python.LoadVarargsRoutine) }
  4.  

I didn't much expect the last of those to work, but thought it worth checking the various possibilities.

MarkMLl






Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

PascalDragon

  • Hero Member
  • *****
  • Posts: 3059
  • Compiler Developer
Re: Verify existence of a variable
« Reply #16 on: April 21, 2021, 01:56:27 pm »
Observations without intending to be critical: playing around, I notice that if I have a unit called Python this fails:

Code: Pascal  [Select][+][-]
  1. {$if declared(LoadVarargsRoutine) }
  2.   Python.LoadVarargsRoutine('*', true); (* Try to load all varargs routines     *)
  3. {$endif }
  4.  

PythonDemo.lpr(86,5) Error: Evaluating a conditional compiling expression

while this is successful:

Code: Pascal  [Select][+][-]
  1. {$if declared(LoadVarargsRoutine) }
  2.   Python.LoadVarargsRoutine('*', true); (* Try to load all varargs routines     *)
  3. {$endif }
  4.  

Am I blind or what is the difference between those two? :o

Anyway, can you please provide a small, self contained example that shows the problem?

If instead of being a unit Python is an instance of class TPython (contained in unit python_dynamic which has been appropriately imported) then neither of these forms works:

Code: Pascal  [Select][+][-]
  1. {$if declared(TPython.LoadVarargsRoutine) }
  2. ...
  3. {$if declared(Python.LoadVarargsRoutine) }
  4.  

I didn't much expect the last of those to work, but thought it worth checking the various possibilities.

Scoped identifiers names are not yet supported. They are somewhere on my ToDo list however as I had stumbled upon this in the past as well.

MarkMLl

  • Hero Member
  • *****
  • Posts: 2700
Re: Verify existence of a variable
« Reply #17 on: April 21, 2021, 03:16:04 pm »
Whoops! I /am/ sorry about that... I know how unpleasant it can be. The first should have had a unit name in it, demo attached.

(Edited since I'd screwed the attachment)

MarkMLl
« Last Edit: April 21, 2021, 03:33:55 pm by MarkMLl »
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018