microsoft / advanced-formula-environment

Create, edit, and reuse formulas in Excel
https://aka.ms/get-afe
MIT License
109 stars 11 forks source link

Dot in function name in Workbook is allowed but not in any other module #48

Open dlealv opened 1 year ago

dlealv commented 1 year ago

I realized that you cannot use the dot (.) character in the name of the function in any other Name different than the Workbook:

image

no error, but:

image

I would say the naming convention should be the same, and follow Excel naming conventions.

jack-williams commented 1 year ago

This is ‘by design’. You can use dotted names in the Workbook module because these are saved into the name manager without a prefix. They are design to be consistent with existing name manager names. Other modules will add their name as a prefix, so you write modulename.definedname. For these so-called ‘qualified’ names, having dots in the name itself is messy to implement and non-standard when compared to other languages. The aim of modules is to be more like typical languages.

dlealv commented 1 year ago

Thanks, @jack-williams but I am not agreed with the approach from the user perspective. The naming rules should be the same, regardless of the tab. The way I use additional workbooks is as a library and Workbook for working progress work, not refined yet. So I cannot move certain functions because the naming rules are not the same. On top of that, this limitation is not documented.

I found out that we need to add the name as a prefix, which surprised me, I thought we can call the function not referring to the namespace, so they are unique regardless of the namespace, but I see the advantage of it, you can define the same function name on different namespace with no conflict, even though I don't see the practical use of it. Per my understanding the Function Names are at the Excel file level, so you can have different Excel files with the same function name. AFE allows to have more than one tab, as an extra functionality, but it all refers to the same Excel file, correct? Maybe for a large Exel file, it makes sense to have different Names so you can separate them by certain criteria, OK.

Imagine you have a formula in Excel in a tab (Sheet1), then you create a new tab and move the formula there, it doesn't work because the naming rules are different from the first tab and the rest of them. This is how I see it, it doesn't make any sense.

The naming rules for functions should follow the same rule and limitations Excel has, since using a dot is not a limitation AFE should respect that, it is a proxy of Excel, and it should not restrict the Excel naming conventions. I understand it is an easy solution from the implementation point of view, but not a good design decision.

For example in Workbook you can define the following: TEST.A.B.C.D.E = LAMBDA(x,x);

so you can use as many dots as you want, not an issue. Excel uses dots to specify variants of a given function, such as RANK.EQ from RANK similarly PERCENTILE.EXC, PERCENTILE.INC which makes sense, I am trying to use the same logic, but I cannot because of this limitation AFE has.

"...non-standard when compared to other languages"

Depending on the language, for example, AWS uses :: to delimit the namespace, similar to C++. It is true for Java and Python (for example check this: namespace). I wouldn't say there is a standard for that, but that is another debate. In Object Oriented Programming yes the dot is used to refer to a given method of the class, but Excel is not a language, not even an Object Programming Language. Excel is a product that has VBA and Office Script as languages, but it is not a language itself.

Being consistent, the : is not an allowed character for the function name in Excel, so I would consider this approach instead. I know it is a change, but I think it is about the same implementation, and more consistent with Excel, under this approach you can refer to the namespace and be able to use .as part of the Excel function name, for example:myLib:TEST.MS is less disruptive and doesn't brake any Excel function name. In case you want to keep the rule to force the user to use the namespace as a prefix, I don't see the value of it.

I am pretty sure users can live better with the fact that you can have multiple name tabs, but the function name needs to be unique rather than allow the user to use the same name on different tabs, but then you need to enter every time the tab name a prefix.

For sure, from the implementation point of view, it is more complicated than just changing . to allow now : notation, or allowing . in the name of the function on every tab, forcing the function name to be unique across all tabs and not forcing the user to add the tab name as a prefix in Excel.

In case you want to take into consideration my feedback for the future evolvement of AFE.