[Gambas-user] Request for comments about a language change

B Bruen bbruen at ...2308...
Sun Jun 1 03:32:22 CEST 2014


The only possible problem I can think of is where the enumerated set "becomes" null during the iteration. But quick testing shows that the iteration is done on a copy of the set as at when the For Each is first entered.  On the other hand, you might want the enumeration to "automatically end" in the event that the set becomes null? This can currently be done by testing the set at each iteration. Would this change make this happen "automatically"? This could have side effects with existing code.

On Sun, 1 Jun 2014 03:25:26 +0300
Jussi Lahtinen <jussi.lahtinen at ...626...> wrote:

> Oh, of course all enumerable classes, I was thinking command ENUM...
> I try to think whether there could be situation where this would hide error
> in code.
> If for some error you pass Null object to this:
> 
> Public Function CountLargeObjects(hArrayOfObjects As Object[]) As Integer
> 
>   Dim hObject As Object, iCount As Integer
> 
>   For Each hObject In hArrayOfObjects
>     If hObject.Size > 100 Then
>     Inc iCount
>     Endif
>   Next
> 
>   Return iCount
> 
> End
> 
> 
> Then it may be harder to catch.
> But I don't think that is big deal, if this change has some great
> potential..?
> 
> 
> Jussi
> 
> 
> 
> On Sun, Jun 1, 2014 at 2:28 AM, B Bruen <bbruen at ...2308...> wrote:
> 
> > > On Sat, May 31, 2014 at 2:38 PM, Benoît Minisini <
> > > gambas at ...1...> wrote:
> > >
> > > > Hi people,
> > > >
> > > > Does anybody have an objection against the following change:
> > > >
> > > > "For Each Value In Enumeration" raise an error if `Enumeration` is
> > NULL.
> > > >
> > > > I suggest that instead it does nothing, as if Enumeration was a void
> > array.
> > > >
> > > > What do you think?
> > > >
> > > > --
> > > > Benoît Minisini
> > > >
> >
> > So, :
> > 100  Dim aTest As String[]
> > 101  Dim sItem As String
> > 102
> > 103  For Each sItem In aTest
> > 104    Print sItem
> > 105  Next
> > 106  Print aTest.Count
> >
> > would just just fail at line 106 rather than 104?
> > No objections, I just cant see the point?
> >
> > regards
> > Bruce
> > --
> > B Bruen <bbruen at ...2308...>
> >
> ------------------------------------------------------------------------------
> Time is money. Stop wasting it! Get your web API in 5 minutes.
> www.restlet.com/download
> http://p.sf.net/sfu/restlet
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user


-- 
B Bruen <bbruen at ...2308...>




More information about the User mailing list