gnudatalanguage / gdl

GDL - GNU Data Language
GNU General Public License v2.0
277 stars 61 forks source link

Problem running proceures without pro #1868

Open jaymurthy opened 4 months ago

jaymurthy commented 4 months ago

This program works ok on Sonoma 14.5 pro temp print,'test' end

If I remove the pro temp, it doesn't print anything. It used to work in 1.0.6-1gf84626e7 $ cat temp.pro print,'test' end $ gdl GDL - GNU Data Language, Version v1.0.6-16-gc154de16

GDL> .run temp GDL>

ChunkyPanda03 commented 3 months ago

@jaymurthy I do believe that what you are talking about is running a file as though it was the module main. IDL handles this by running the main module with the .go command not .run, .run will never work as there is no procedure temp. From my understanding IDL % Compiled module: $MAIN$. and then runs the staged commands with the .go command (once again this is not a file). An issue I have found is that there is no .go implementation in the gdl version v1.0.6-18-ga5083893-dirty which is the version I am running.

GDL> .go
GO not implemented yet.
ChunkyPanda03 commented 3 months ago

@jaymurthy I would suggest changing the title to something like .go command has no implementation.

jaymurthy commented 3 months ago

You may be right but I've always run files like that and it has worked in GDL in the past. (Sreenshot attached).

Screenshot by Dropbox Capture

GillesDuvert commented 3 months ago

Interesting, indeed IDL does:

IDL> .run temp
% Compiled module: $MAIN$.
testing
IDL> .go
testing

So this would be a regression. IDL documentation says that .run can run 'main' programs, such as temp.pro

In the absence of '.go' (remember, GDL was not initially written for interactive development, only playing 'old' IDL programs :smile: ) .run temp is more or less@toto where toto is temp.pro without the 'end'.

jtappin commented 2 months ago

Coming in a bit late on this one.

In the absence of '.go' (remember, GDL was not initially written for interactive development, only playing 'old' IDL programs 😄 ) .run temp is more or less @toto where toto is temp.pro without the 'end'.

@ should (and I think is) be a strict line-by-line processing (I stopped using the @ method for anything beyond 1 line as changing the code while it was running produced seriously weird effects). Therefore blocks can only be made to work by using continuation lines, e.g. if prt.pro is:

for i = 0, 4 do begin
   print, i
endfor

gives:

GDL> @prt
% Parser syntax error: unexpected end of file
% PRINT: Variable is undefined: I
% Execution halted at: $MAIN$          
% Parser syntax error: unexpected token: ENDFOR
GDL> 

but:

for i = 0, 4 do begin & $
   print, i & $
endfor

does what is expected.