Kara-Moon Forum

Developers & Technology => Musical MIDI Accompaniment (MMA) => Topic started by: bvdp on January 23, 2021, 11:42:21 PM



Title: Version 20.12.1 Available
Post by: bvdp on January 23, 2021, 11:42:21 PM
I have just posted a "developer" version of MMA on our website.

    https://mellowood.ca/mma/downloads.html#developer

As always, please have a go with the new features and let me know if you find any problems.


Title: Re: Version 20.12.1 Available
Post by: sciurius on January 24, 2021, 02:12:36 PM
Thanks, good job!

I've noticed that even though the site reads "please read the file text/CHANGES-** for complete details" the CHANGES-20 file doesn't have a section for 20.12.1.

RPMs for Fedora and other RPM based Linux distros are downloadable from https://www.squirrel.nl/pub/MMA/ .


Title: Re: Version 20.12.1 Available
Post by: sciurius on January 24, 2021, 02:51:34 PM
Calling a subroutine with insufficient number of arguments no longer gives an error, but the missing arguments get the value "UNDEFINED".

This is not documented, and not in the CHANGES file.

Now we can test for empty values, wouldn't is be better to change the missing argument values to empty instead?

Even better maybe: check for the correct number of arguments as in previous versions, but allow Default to specify an empty value, e.g.

Code:
DefCall Foo Bar
Default Bar
IfEmpty Bar
...
EndIf
EndDefCall

Does that sound sensible? As long as it is not documented we can change it...


Title: Re: Version 20.12.1 Available
Post by: bvdp on January 24, 2021, 10:44:22 PM
I've noticed that even though the site reads "please read the file text/CHANGES-** for complete details" the CHANGES-20 file doesn't have a section for 20.12.1.

Nice to see the continued posting of the RPMs. Appreciated.

The CHANGES file should be read from the bottom up. The new stuff is that upto the last release (in this case 20.12). Usually, I have a line "Released xx.xx ..." at the bottom of the file. Somehow I missed that ... and I don't know why! Oh well, it is there now.


Title: Re: Version 20.12.1 Available
Post by: bvdp on January 24, 2021, 11:04:34 PM
Calling a subroutine with insufficient number of arguments no longer gives an error, but the missing arguments get the value "UNDEFINED".

This is not documented, and not in the CHANGES file.

Now we can test for empty values, wouldn't is be better to change the missing argument values to empty instead?

Even better maybe: check for the correct number of arguments as in previous versions, but allow Default to specify an empty value, e.g.

Code:
DefCall Foo Bar
Default Bar
IfEmpty Bar
...
EndIf
EndDefCall

Does that sound sensible? As long as it is not documented we can change it...

I'm not sure if the UNDEFINED thing should be there ... it might be a leftover from testing. But, what are we screwing around with this ... you can already set default values when you define a subroutine.

Code:
DefCall FunName2 arg1=123 
 print $arg1
EndDefCall

Perhaps the missing part is that you can't set arg1 to a null? Well, you can:

Code:
Set foo
Call FunName2 Foo
DefCall

which prints "UNDEFINED" ... hmm, I think the idea was that the function would check for the value "UNDEFINED" and act accordingly. However, if you change line 175 in func.py from "UNDEFINED" to "" it might work?? No, it doesn't ... but " " does. The problem is not in the function but in the other macro handlers ... I hate to start to work all though this for an exceptional case and introduce some other problems.




Title: Re: Version 20.12.1 Available
Post by: bvdp on January 24, 2021, 11:05:09 PM
And I will add the UNDEFINED issue to the docs :)


Title: Re: Version 20.12.1 Available
Post by: bvdp on January 24, 2021, 11:44:47 PM
I will look, again, at the UNDEFINED code and do a walk though to see if there is a simple solution :)


Title: Re: Version 20.12.1 Available
Post by: sciurius on January 25, 2021, 07:22:08 AM
The question originated when I tried to find a way to call a subroutine both with and without arguments, without having to specify a default value.

At the time I used

Code:
DefCall Foo Chords=__OMITTED__
 If Ne $$Chords __OMITTED__
    ...
 EndIf
EndDefCall

This works, but now we have the possibility to test for empty, it would be better to use that. AFAICS the only required change would be to allow the second argument to Default to be omitted, just like wih Set:

Code:
DefCall Foo Chords
 Default Chords
 IfEmpty Chords
    ...
 EndIf
EndDefCall

I think it is valuable that the parameter validation still works. Leaving out parameters when they should be there should always signal an error.


Title: Re: Version 20.12.1 Available
Post by: sciurius on January 25, 2021, 09:28:00 AM
With the attached minimal patch, the following test passes:

Code:
DefCall Foo Chords
  Default Chords
  If IsEmpty Chords
    print Call Foo with no args
  Else
    print Call Foo with $Chords
  EndIf
EndDefCall

Call Foo Bar
Call Foo

AFAIC the UNDEFINED hack can go.


Title: Re: Version 20.12.1 Available
Post by: bvdp on January 25, 2021, 05:01:53 PM
Looks like you beat me to it :) I'll run this though the torture test later ... Thanks.