Euphoria Ticket #658: defaulted parameter expression parsing

Assume that XYZ has not been defined, anywhere, yet

procedure p(integer i=XYZ)  
  puts(1,"this is p\n")  
end procedure  
  
p(0)  


compiles cleanly, until you delete the 0, in which case you get an error on line 5 rather than on line 1...

Assuming then that defaulted parameters are implemented by some kind of text substitution, this means you have the contextual gotcha:

inc.e is:

constant x = "12345"  
global procedure p(integer i=length(x))  
  printf(1,"the length of %s is %d\n",{x,i})  
end procedure  


test.exw is:

include inc.e  
constant x = "123"  
p()  


which prints "the length of 12345 is 3"

If you remove the second x, it gives better results, but then that implies it is successfully referencing the private x of inc.e out-of-scope (or the private x of test.exw out-of-scope, whichever way you want to look at it)...

My argument is that parameter defaults should be parsed in the context of their definition, not differently in each different context of each different call, or more alarmingly not at all.

Details

Type: Bug Report Severity: Normal Category: Front End
Assigned To: unknown Status: Duplicate Reported Release:
Fixed in SVN #: View VCS: none Milestone:

1. Comment by petelomax Apr 28, 2011

Sorry, this is a duplicate of ticket 563

Search



Quick Links

User menu

Not signed in.

Misc Menu