Author Topic: Catching nonexistent function arguments  (Read 385 times)

Offline DavidW

  • Planewalker
  • *****
  • Posts: 281
Catching nonexistent function arguments
« on: March 31, 2019, 08:00:52 PM »
How straightforward would it be for WEIDU to give a WARNING if you send an argument to a function that isn't actually defined for that function? As in:

Code: [Select]
DEFINE_ACTION_FUNCTION square_this
   INT_VAR input_variable=0
   RET value
BEGIN
OUTER_SET value=input_variable * input_variable
END

LAF square_this INT_VAR input=4 RET value END

At present, WEIDU just ignores 'input' and uses the default value for 'input_variable'. In some contexts that leads to annoying silent errors, where it looks as if (e.g.) something's being patched but actually you mistyped the input.

Obviously it would need to require a preamble declaration to avoid breaking backwards compatibility: USE_STRICT_FUNCTIONS or something similar.

Offline The Imp

  • Planewalker
  • *****
  • Posts: 281
  • Gender: Male
Re: Catching nonexistent function arguments
« Reply #1 on: March 31, 2019, 09:45:02 PM »
I suppose this request is made with intention where the mod maker reads the entire .debug file to find the instances of input errors ? Perhaps it could be added to the MODDER mode ?

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1064
Re: Catching nonexistent function arguments
« Reply #2 on: April 20, 2019, 08:52:35 AM »
Since MODDER is the established method for toggling these sorts of things, and this feature is of no use in production, would a MODDER option be acceptable?

Offline DavidW

  • Planewalker
  • *****
  • Posts: 281
Re: Catching nonexistent function arguments
« Reply #3 on: April 20, 2019, 10:19:28 AM »
Absolutely.

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1064
Re: Catching nonexistent function arguments
« Reply #4 on: April 21, 2019, 08:27:31 AM »
Done. MODDER option FUN_ARGS will check that all LAUNCH arguments are also DEFINE arguments.

Offline DavidW

  • Planewalker
  • *****
  • Posts: 281
Re: Catching nonexistent function arguments
« Reply #5 on: April 21, 2019, 10:19:08 AM »
Terrific!

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: