View Single Post
Old 10-08-2022, 09:52 AM   #13
un_pogaz
Chalut o/
un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.
 
un_pogaz's Avatar
 
Posts: 439
Karma: 145424
Join Date: Dec 2017
Device: Kobo
Quote:
Originally Posted by kovidgoyal View Post
I dont particularly mind having new versions create things that dont work in old versions, but I frown on the other way. That is things from old versions should preferably not stop working when going to a new version as much as possible.
Perfectly understandable.

Quote:
Originally Posted by chaley View Post
That isn't how it works. The arg count is irrelevant. If the text of the stored 'whatever' starts with 'def' then it is a python function. If it starts with 'program' then it is a template function. Anything else is illegal.
Okay, so its the code itself that defines its type, what about...

Quote:
Originally Posted by chaley View Post
The requirement that template functions have either -1 (unspecified) or >= 1 arguments is there to help someone avoid writing functions that can't be called in single function mode. I have considered removing that requirement. For example, this template function with no arguments works.
Code:
def evaluate(self, formatter, kwargs, mi, locals):
	return 'aaa'
I don't see the need for this. You can already define functions with zero arguments using -1. If I remove the restriction then you would be able to use an arg count of zero without requiring any migration.
Yes, removing this restriction would be nice.
But as there is a workaround easy to implement, detail.
Thanks

But I'm really curious to understand why it should be avoided to create a 0 arg function by default, what would be the risks and problems?
It seems to me absurdly arbitrary , hence my theory 0 'Stored template' / +1 'function', I'm trying to find a way to make sense of it.

Last edited by un_pogaz; 10-08-2022 at 09:56 AM.
un_pogaz is offline   Reply With Quote