sancarn / stdVBA

VBA Standard Library - A Collection of libraries to form a common standard layer for modern VBA applications.
MIT License
294 stars 58 forks source link

useStdEnumerator conditional compiling. #23

Closed sancarn closed 2 years ago

sancarn commented 3 years ago

It might be a good idea to write all declares which return a collection as the following:

#if useStdEnumerator then
Public Function Filter(Byval filter as stdICallable) as stdEnumerator
#else
Public Function Filter(Byval filter as stdICallable) as Collection
#end if

  #if useStdEnumerator then
    set Filter = stdEnumerator.CreateFromIEnumVariant(ret)
  #else
    set Filter = ret
  #end if
End Function

In this way, all stdVBA modules can be quickly ported to using stdEnumerator with the flick of a compiler switch. Similarly stdError and Err could be used based on a compiler argument.

Note: i did have another idea for stdError specifically in #10

sancarn commented 2 years ago

I disagree with my past self. I did try to make this work but it's too messy. In reality if we want this it should be as part of a build process, because these conditional compiling arguments make the modules a complete mess unfortunately.

So a better idea is transform all statements that are like:

set Filter = ret into set Filter = stdEnumerator.CreateFromIEnumVariant(ret) assuming that ret is a Collection and the return value of the function should be a Collection. This should be part of a build process for building a stdVBA VB project, which can be included in as a dependancy.