Type detection: Difference between revisions

Content deleted Content added
→‎{{header|zkl}}: added how to use
updated discription
Line 1:
{{draft task|FIXMEType detection}}
{{Alertbox|pink|This page is scheduled for deletion after 09-Oct-2015. - See discussion page'}}
 
{{draft task|FIXME}}
This draft task needs a purpose, a description and some way to tell whether examples satisfy or do not satisfy it.
== Task Description ==
Show a function/procedure that, when given an object of type Any (or just unknown type), performs a common task.
 
ForThe example:task you wantis to processshow a block of text. The function takes a parameter/procedure that is,processes or somehow describes, thea block of text (andby providesprinting ait. methodThe orfunction calltakes toone accessparameter and return(ideally) that blockdescribes ofthe text). TheDemonstrate taskby iscalling then to show howthe function getstwice, theeach texttime frompassing thein parametera (butdifferent not show the text processing)type.
 
This can be done with pattern matching, multi-methods, dynamic type detection, structs with a tag, etc. The objective is write one [eg library] function that processes text from multiple sources (such as a string/char *, socket, file, etc). If not practical, show how the caller would coerce a type that can be passed to the library function.
== JavaScript ==