On 19 Aug 2018, at 7:56pm, Warren Young <[email protected]> wrote:

> On Aug 19, 2018, at 10:03 AM, Norman Dunbar <[email protected]> wrote:
> 
>> Duck Typing? Never heard that before.
> 
> It’s a pretty common term of art in the software development world:
> 
>   https://en.wikipedia.org/wiki/Duck_typing

That article was written 20 years too late.  Duck Typing was around before 
everything had methods and properties.  An early form of Duck Typing looked 
like this (pseudocode, not a real language):

* Attempt to figure out what kind of value is in A
* without risking the program crashing
* A is source, B is result, T is temporary and can be lost
* 
LET T = A + 11
* If A is a string, plus appends, and T is now a string ending in "11"
* If A is a number, T is a number, but cannot be 2 characters longer
* 
IF LEN(T) = LEN(A) + 2 THEN LET B = "string" ELSE LET B = "number"

Because of the limitations of programming languages at the time, you were often 
limited to passing just one parameter or one variable.  But using a string 
function on a number, or vice versa, would crash the program with an error 
message.  Hence code like that.

Simon.
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to