microsoft / advanced-formula-environment

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

Please add support for Lambdas in the local scope #88

Open ovonrein opened 4 months ago

ovonrein commented 4 months ago

Nothing to add to the title. I am unclear why AFE completely ignores names in the Worksheet scope.

jack-williams commented 3 months ago

AFE was originally created as a way to author LAMBDA's that could be shared across documents, and worksheet scope coupled the functions to the document. Since then, AFE has expanded to support name manager capabilities but we have not prioritised parity with the name manager as that was never a goal.

We currently do not have plans to add this and in terms of feature priority, we would rather add more features for sharing functions across documents. Will add this as a feature request for tracking.

ovonrein commented 3 months ago

Thank you for your reply, Jack.

We share a goal – although our approaches differ considerably. I too need to worry about keeping (global) Lambdas up to date across our Excel environment. The way I do this is via simple Notepad text files. Example copy from one such:

' SAMEROWS/COLS extracts from super_range a subset of rows/columns that corresponds to row/columns of sub_range. This is ' useful when you have a named range spanning some rows/columns and you are trying to grab the same rows/columns in ' a different (unnamed) column/row. For example, when using SUMIFS, you may know the sum_range and want to derive ' the corresponding criteria_range, eg =SUMIFS(sum_range,SAMEROWS(A:A,sum_range),"*"). ' 20/01/2023 V1.0, OVR

SAMECOLS = LAMBDA(super_range,subrange, LET( subCol1, COLUMN(INDEX(subrange,1,1)), subColN, COLUMN(INDEX(sub_range, 1, COLUMNS(subrange))), supCol0, COLUMN(INDEX(superrange,1,1)) - 1, INDEX(super_range,1,subCol1-supCol0):INDEX(super_range,ROWS(superrange),subColN-supCol0) ))

These .lbd files are distributed to team members via Sharepoint and read into each XLSM upon startup via VBA. This works so well that I have not kept up to date with recent developments of AFE in that respect.

To maximize my control over the source code of Lambdas, I too wish to “globalize” Lambdas as much as possible. To that end, I take a two-tier approach. Conceptually speaking, this looks like so:

Worksheet!myLambda(Private.myLambda(range1, range2, …))

Workbook!Private.myLambda(wsRange1, wsRange2, … LET( … ))

That is, the local myLambda – the “public face” of myLambda – does nothing more than to provide the local Worksheet context into the global Private.myLambda, which does all the work and which I can control thru my .lbd file.

Now, what I am more interested in as regards AFE are your recent efforts to provide debugging for Lambdas *). But here I come totally unstuck because the AFE debugger refuses to look thru the local myLambda and any attempt at debugging the global Private.myLambda hence fail. Which is frustrating.

Kind regards – ovr.

*) I must admit that I have not quite understood the mnemonics yet of the AFE debugger but I am sure that fault lies entirely with me. (Is there a tutorial somewhere?) I also have issues with the GUI. I cannot figure out how to stop the Lambda signature from taking up 50% of the screen real estate. I only really care to see the code... ☹

From: Jack Williams @.> Sent: 20 August 2024 09:00 To: microsoft/advanced-formula-environment @.> Cc: Olaf von Rein @.>; Author @.> Subject: Re: [microsoft/advanced-formula-environment] Please add support for Lambdas in the local scope (Issue #88)

AFE was originally created as a way to author LAMBDA's that could be shared across documents, and worksheet scope coupled the functions to the document. Since then, AFE has expanded to support name manager capabilities but we have not prioritised parity with the name manager as that was never a goal.

We currently do not have plans to add this and in terms of feature priority, we would rather add more features for sharing functions across documents. Will add this as a feature request for tracking.

— Reply to this email directly, view it on GitHubhttps://github.com/microsoft/advanced-formula-environment/issues/88#issuecomment-2298216762, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BJYG54DTHIM5Y3AVVH4VPMDZSLZO7AVCNFSM6AAAAABKTE5UBKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJYGIYTMNZWGI. You are receiving this because you authored the thread.Message ID: @.***>