Re: Stupid Newbie-sounding question.

new topic     » goto parent     » topic index » view thread      » older message » newer message

>From: Derek Parnell <guest at RapidEuphoria.com>
>Subject: Re: Stupid Newbie-sounding question.
> > Okay Rob... What sort of structure do these sequences have to have? I 
>don't
> > know! If we had the ability to use stronger typing, then function
> > myFunc(text_picture r1, string r2, flag_list r3) would make a lot more
> > sense. I could go and look at the type declaration, and figure out what 
>to
> > pass to the function.
> > People don't use the types like this at the moment because it's so damn
> > computationally expensive for sequences.
>
>This is true. And there is the trade off - speed & flexibility against
>structure and complexity. Think of it in terms of a bicycle without
>training wheels and one with training wheels blink
>
>RDS has chosen speed. Meaning that the coder has more responsibility to
>provide quality assurance than the translator does. Yes this does mean
>more work for the coder and better discipline.

Well, if you're writing a library that other people would use, I would say 
that it's the library programmer's responsibility to check the data passed 
to it.

I think that types could be implemented in a way that would run *faster* 
than without. Without these types, libraries and functions need to check 
that the data passed to it is valid. This results in redundant checks. 
Having types supplemented with the "of" command speeds it up many-fold over 
the old type system, because data will only be checked that has changed. And 
because that if a variable is of a certain type, it is *known* already that 
it is valid, so it won't need to be checked multiple times.

> > Issue #2:
> > Run-time slicing and sequence errors are my main cause of problems. The
> > primary error I make is missing a set of braces around a concatenation
> > command....
>Learn to love the append() function.

I know, but '&' uses less keys... (my bad, I know).
It's still a valid argument (slicing and seq errors). It's very easy to 
misplace a subscript, or make some error if you are breaking up and 
reassembling a sequence in one line.


> > Unfortunately, I only find out when I try to reference it, which may be 
>a
> > long way from this error. At least with differential checking, an error
> > would show up at that point of error, and I can fix it quicker.
>
>This is also an arguement for some type of 'assert' system that would help
>trap errors during development and could be automatically removed for the
>release version.

Well, type checking could be turned off for release. The user won't know how 
to fix a code error, no matter how helpful the error message.

>Ummmm? Why not code so that it works?
>
>  type myStruct (object s)
>      if sequence(s) return 1
>      else return 0
>  end type

Because it is non-intuitive.
Because there is no shortcut for 'and' in this form:
type myStruct ( object s )
    return sequence(s) and length(s) = 4 and integer(s[1])
end type
Crashes if not a sequence.



Derek, if someone passes a badly-formed sequence into one of the Win32lib 
functions, the error is stated to be inside that function, when in fact it 
was the fault of the other programmer. The trace window or ex.err may show 
the value of the sequence (or maybe only the first part), but it may not be 
easy to elucidate that a) the error resulted from their own mistake. b) 
Exactly what was wrong with that sequence they passed, anyway.
MrTrick

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu