« first day (1475 days earlier)      last day (1705 days later) » 
00:00 - 20:0020:00 - 00:00

8:00 PM
for performance reasons it says? I think that is actually the variable name
 
the line 249 is throwing me off - this is the lExpr whereas the line 254 is assigned to indexExpr
but as I said, I have weak understanding and might be reading it totally wrong.
 
// We treat redim statements as index expressions to make it SLL.
can just put a breakpoint there and see what it does :P
 
yeah. that'd be easier. :)
but when you pointed that comment out, I now see what it's meaning. You're prolly right.
 
it might already be adding an UnboundMemberDeclaration?
in AddUnboundContext, so all that's missing is someone somewhere checking if it's a redim statement and then adding a declaration for it or something like that
 
I smell an incoming PR...
;-)
 
8:14 PM
it already creates an implicit variant variable :O
* declaration
 
Question: does a ReDim act in its function as a declaration like a Dim, i.e. does it affect the entire procedure?
 
depends.
@MathieuGuindon @M.Doerner in this linked example, it's also a declaration, assuming there are no public variable of the same name.
 
@awgaya yeah, that's how the "variable is not declared" inspection picks it up
we need to be creating the declaration before it gets to that
 
The key is that the variable in the Redim has to be basically undeclared by any other Dim/Private/Public statements, then in that case, it's basically also an implicit Dim statement.
 
oh ok
 
8:20 PM
That said, it's a one big filthy code smell because you'd never know by looking at the procedure alone whether we have a local variable or if we're mutating some public variable.
 
"TODO - this is a complete and total hack to prevent Mid and Mid$ from creating undeclared variables"
 
Hm? Don't we correctly resolve them correctly now anyway?
 
well, not a lot of things from referenced libraries resolve correctly right now... or did I miss something?
that TODO must predate the Mid/Mid$ resolver fix though
 
hmm. the blame still attributes to comintern
 
it should be pretty simple though right, if the redim variable simple name expression lookup fails = not declared thus we have to create a declaration ourselves
 
8:30 PM
the issue was closed as no-repro but a better test would be to remove those lines, then re-test.
 
the undeclared variable bit for the mid stuff is in the way though
 
I did not know anything about this comment when I fixed the statemets.
 
this is too simple.. why wasn't ReDim made to create declarations then?
 
@M.Doerner if your fixes were somewhere else, then we should be able to remove the line 80 and 85?
 
there's a todo there for that :P
// TODO: Create local variable if no match for redim variable declaration.
 
8:32 PM
@MathieuGuindon #BecauseWeWereLazyBackThen ?
 
never done it though
 
You could just try to remove the mid stuff and see what happens.
 
@this scanning transcript to see if I can't find something
 
The less TODO we have in the resolver (really the whole codebase) the better. Esp in resolver which is quite complex (at least it is to me)
 
you're talking about this right? github.com/rubberduck-vba/Rubberduck/blob/…
 
8:33 PM
@this not just to you ;-)
 
I think I fixed the Mid statement at one point; the Mid function should be covered by the custom alias declarations.
 
just remove that if statement?
ok
//pending an actual fix to the grammar. See #2618
 
I fixed the grammar.
 
@awgaya TBH IDK - i'm just going off the blame, which still has 80 and 85 line attended to the hacky fix PR
 
ok
 
8:34 PM
At least, I think I did.
I just never new about that comment.
 
whether the lines between 80 and 85 are needed... need to look at the history a bit more.
 
@M.Doerner I don't see a PR from you involving "Mid"
 
...and re-reading it, I still can't see why we haven't done it
 
woah. I never realized you could As <type> on a Redim statement!
 
8:41 PM
at least there's a compiler error for trying to change the data type of array elements
Sub test()
    ReDim foo(1 To 10) As String
    ReDim foo(1 To 20) As Long 'illegal
End Sub
 
yeah thank goodness
 
soo ... sidequestion: do we want next release to be a 2.3.0?
or a 2.2.1?
 
Mar 25 '17 at 3:26, by Comintern
loc_10200A28:
lea     eax, [esp+24h+psaboundNew]
push    eax             ; psaboundNew
push    dword ptr [esi] ; psa
call    ds:SafeArrayRedim
test    eax, eax
js      short loc_10200A48
 
but why did ThunderFrame's code compile?
@Vogel612 my vote's for 2.3 when VB6 goes live.
 
@this Nor did I.
 
8:43 PM
@Vogel612 with VB6 support and AutoComplete, I'd be inclined to call it 2.3 also
 
If we release before that it's 2.2.1
hm. even if we release AC, that's pretty much a 2.3, too.
 
2.2.1 should have been the hotfix release that never was
 
IKR!
We suck at hotfixing. :P
 
I know I do
 
there's also that stupid ghost process at exit thing. :\
 
8:44 PM
@this well, 98-percent-there-AC is already in next, so...
 
@Vogel612 OK, I think I misremembered. However, more of my PRs incuded grammar changes.
 
@MathieuGuindon I wouldn't really mind releasing the current next as a 2.3.0-RC (because AC is buggy)
and then releasing 2.3.0 with RC and some more bugfixes
also large parts of vb6 are already in [next] as well
 
current next doesn't resolve referenced libraries, last I checked
 
@MathieuGuindon, Ok I see, I think why ThunderFrame's code works...
Dim foo As Variant
ReDim foo(0) As Long
ReDim foo(1) As Boolean
This is legal
 
yeah, but we'll pick it up as a Variant anyway
so, not really a problem
 
8:47 PM
omit the Dim foo As Variant, it'll fail. Yeah.
whew
 
I haven't had any ghost Excel process for a while. Crash on exit every now and again.
 
VBA is.... funky
You almost could say it's JavaScript's father.
 
> The ReDim statement acts as a declarative statement if the variable it declares doesn't exist atmodule level orprocedure level. If another variable with the same name is created later, even in a wider scope, ReDim will refer to the later variable and won't necessarily cause a compilation error, even if Option Explicit is in effect. To avoid such conflicts, ReDim should not be used as a declarative statement, but simply for redimensioning arrays.
 
20 messages moved to trash, because Duga isn't picky about having her messages moved
 
8:55 PM
@awgaya we'll need a way to flag a Declaration that was created off a ReDim statement - we need an inspection for that
(similar to how undeclared variables get flagged)
 
check it's context
 
@IvenBach and that's why the declarative use of Redim is dangerous - it violates the Option Explicit's protection, basically.
 
we want to not put more stuff into Declaration
it's horribly bloated as is anyways
 
@Vogel612 you know what, you're right... Declaration needs to stop trying to be a Helper
 
we already have an open issue for simplifying it
 
8:56 PM
Helper? Are you sure it's not god already?
 
what we desperately need for Declaration is the notion of discriminated record types
 
what's that?
 
isn't that what we are kind of doing (or did) with inspection and its Type member?
 
basically something like polymorphic subclassing, but without the need to add separate implementations
 
hmm, we already have ParameterDeclaration, ProcedureDeclaration, and a bunch of other subclasses... we're just not using them as much as we should
 
8:58 PM
you can add members to a type that are only present if a field in that type has a specific value
 
yeah the base class knows too much about everything that could possibly ever be declared
 
and if you can prove to the compiler that the field has that value, it lets you use the members without you needing to cast
 
does that exist in C#?
 
no
well, not yet
 
would contravariant generic help us out (giving us the most derived class)
 
9:01 PM
probably, yes
if you throw some of the important bugs onto the 2.3 milestone, that'd be great, btw
 
Really, we just need a bunch more subclasses for Declaration and wire them up in the resolver.
 
I think I'd go for that. That would let us continue to use IDeclaration and do something like GetTheRealThing<out T>, that'd be easiest.
 
sounds good
inb4 some more Duga spam
 
Note that you cannot pass the IDeclaration directlly into that method and get back the derived type.
 
var realThing = declaration.AsSubclass<ParameterDeclaration>(param);
not seeing the point
or would it be
 
9:04 PM
@MathieuGuindon of discriminated records?
it would be:
 
var realThing = declaration.AsSubclass(param); // var is ParameterDeclaration
?
 
I think the idea in their head was that you do not have to specify the subtype.
 
IIUC (and I could be wrong) the contravariance means you should be able to do var realThing = declaration.AsSubClass(param);
Yes, like that.
 
if (declaration.kind == Parameter)
{
    declaration.SomeParameterOnlyMethod();
}
^^ no casting, no nothing
 
9:05 PM
You will have to pass in a dynamic variable to make that work.
 
hm. Is that required?
 
IIUC that doesn't really enable us to get a lot of compile-time information there
 
From what I understood, T AsSubClass<out T>(object param) would work. We're only talking about generic, not dynamic.
 
I wouldn't have object there, but Declaration. no?
 
If you pass an IDeclaration to a T GetFoo<T>(T bar) you will get an IDeclaration.
 
9:06 PM
@MathieuGuindon doesn't actually make a difference
 
The key is <out T>, not just <T>
 
yeah but that's only legal on an interface AFAIK
 
@alexmherrmann welcome to the pond.
 
Because from what I read, it gives you the most derived type without asking for it via a cast?
Bummer if you can only do this w/ interface, though.
 
I'll clean up the Duga mess once she's finished
 
9:09 PM
If something is out T you cannot pass it in, because that would break the contravariance.
 
@M.Doerner but we aren't?
all we are doing is passing in some parameters of something
 
18 messages moved to trash
 
that'll give us the most derived type back, right?
 
@Vogel612 Would be good to get #4098 merged before calling it an RC though... "Hey, thanks for checking out our release candidate, and uh, sorry for nuking your source files!" would be a tough sell :-)
 
9:12 PM
right...
 
Why should it give back the most derived type? and what would T stand for in IDeclaration<out T>?
 
At least that's how I understood it -- let me get the notes on that.
no, i got it backward
we want covariance, not contravariance
 
It still does not make any sense to me.
What type is T?
 
@MathieuGuindon But if it isn't assigned a value, the other function won't work. And I can't assign a value to something private in Module1 from Module2, can I?
 
I'm basing on this code:
Action<Base> b = (target) => { Console.WriteLine(target.GetType().Name); };
Action<Derived> d = b;
d(new Derived());
The desired type for T would be the most derived form of the Declaration - so if we invoke a method AsSubClass() on a Declaration class, we would get back ParameterDeclaration (for example). Ideally without an explicit cast.
 
9:18 PM
Note that covariance just means that you can cast an IFoo<out T> to an IFoo<out S> if 'T' derives from S.
 
right and in all cases, the AsSubClass() would be always a be a derived type of Declaration base class.
 
I am confused now because of the example.
That is an application of contravariance.
However, you want to return something based on T without passing a parameter, right?
 
Yes, I was right the first time but doubted myself. Sorry.
And yes, that's the goal.
 
Now, I am really confused.
 
Thinking about it, it implies that hte derived implementation of the Declaration class has to implement the AsSubClass() and provide the T as itself.
 
9:23 PM
Contravarance works on parameters passed in and covariance on returned parameters.
 
And that's where I got it wrong, then. I am thinking of the return type
 
@Raystafarian hence RD's suggestion to encapsulate it. Make a public getter and expose a setter if you need one, or assign it from Module1.
 
> In general, a covariant type parameter can be used as the return type of a delegate, and contravariant type parameters can be used as parameter types. For an interface, covariant type parameters can be used as the return types of the interface's methods, and contravariant type parameters can be used as the parameter types of the interface's methods.
 
@MathieuGuindon Oh, so make a public sub in Module1 that populates the private variable and just call that from Module2?
 
9:26 PM
Note that what T you get, depends on the interface of the variable you use, not the underlying derived interface/type.
 
But when it's var...?
Hmm. the article doesn't cite any examples when it's just var; they are all explicit declarations.
 
You start with a variable on which you call the function, right?
 
@awgaya We'll be in Austria for F1 on 30/31 June, is that close enough?
 
That variable has to be declared as something.
 
right the idea was it'd be var derived = declaration.AsSubClass()
 
9:31 PM
The declaration will have a declared type.
 
@this If only! Flying is expensive!! (though it's reasonable once you're in the EU)
 
That determines T.
 
it depends on where exactly in austria :P
where are you from then FreeMan? USA?
 
If you want to go for the covariance route, that is.
 
@FreeMan no, free as in free speech, not beers. Like, fly the sky, man. Because you're freeman
 
9:32 PM
Ah, gotcha! :D
 
'Module1
Private someAPIKey As String

Public Sub SetModule1APIKey(ByVal value As String)
someAPIKey = value 'or have it set internally by something within Module1
End Sub

Public Function GetModule1APIKey() As String
GetModule1APIKey = someAPIKey
End Function
If I've understood what you're saying this should be what you're after.
 
So then it would be
`Module2.Main()
'do stuff
' Module1.SetModule1APIKey()
' More stuff
' End Module2.Main
 
Granted you'll want to have proper names for Module and SetModule1APIKey, yes.
 
All right, that makes sense. Thanks @IvenBach @MathieuGuindon
 
Lemme see if I can pull up the encapsulation explanation I read the other day. One moment...
 
9:43 PM
@Raystafarian that's only if you actually need it publicly. If it's only used within the module, you might just as well make it Private
 
^
While the article is about C and C++ the same concept applies: stackoverflow.com/questions/484635/are-global-variables-bad/…
You're the programmer and need to determine if it needs to have public getters and/or setters. It takes time to get comfortable doing so.
 
Right, I think all I would need is to expose a public setter to populate it (private) since it's only used within Module1 (private's scope) with an exposed procedure that takes a different argument and uses the static private
 
In that case, I wouldn't do a property.
It'd be a sub.
a setter-only property is kind of .... strange.
a getter-only property or get/set property are normal, but a set property gives false promise that a sub/function wouldn't.
 
Right, it would never be "getted" by anything since it's implicitly available to the only function that needs it
inherently, not implcitly
I don't see why I didn't see that, there was already a method in place to populate the variable, which I just needed to make public.
 
9:59 PM
The joys of rubber duck coding. Remember the ducky is always right.
 
My duck represents my coding style
 
Oct 18 '17 at 19:07, by IvenBach
My ducky is above my coding monitor. She hears from me more than she wants to.
 
10:26 PM
@this fires an inspection result, too ;-)
@Raystafarian "find all references" is there for that ;-)
 
My problem was I exposed the variable and the sub that populated it, then (in other modules) used the variable and called that sub. I did an extra step for no reason but I just didn't see it
I just want to say that VBA is stupid that it can't easily extract a single "column" (dimension) of an array without looping.
 
without knowing what the array is, I wonder if you really need a single-dimension of UDT or something akin instead of multiple dimension array.
 
10:44 PM
Yeah that's what I've ended up doing, passing a single dimension to a function to populate a separate single dimension of the same size. eh.
 
11:33 PM
OK, the grammar has beaten me for today :-(
think I'll take a step back and write some tests first so I don't have to keep checking manually
but not today. ttgtb
 
@mansellan You'll be in conquer mode tomorrow.
 
@mansellan night!
So I got the wire running across the first floor living room into the garage. Not very elegant, but in-laws aren't here for the rest of the week, so... #tempfix
(they live in my basement while their new house is getting built)
 
00:00 - 20:0020:00 - 00:00

« first day (1475 days earlier)      last day (1705 days later) »