Edit
Attach
Printable
topic end
<!-- * Set TOPICTITLE = Claus Brod: Should Lisp programmers be slapped in public? (17 Jan 2006) --> <style type="text/css"> pre {background-color:#ffeecc;} </style> %STARTINCLUDE% <a name="17"></a> ---+++ [[BlogOnSoftware20060117][Should Lisp programmers be slapped in public?]] (17.1.2006) After fixing a nasty bug today, I let off some steam by surfing the 'net for fun stuff and new developments. For instance, Bjarne Stroustrup recently reported on [[http://www.artima.com/cppsource/cpp0x.html][the plans for C++0x]]. I like most of the stuff he presents, but still was left disturbingly unimpressed with it. Maybe it's just a sign of age, but somehow I am not really thrilled anymore by a programming language standard scheduled for 2008 which, for the first time in the history of the language, includes something as basic as a [[http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/classstd_1_1tr1_1_1unordered__map.html][hashtable]]. Yes, I know that pretty much all the major STL implementations already have hashtable equivalents, so it's not a real issue in practice. And yes, there are other very interesting [[http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1886.pdf][concepts]] in the standard which make a lot of sense. Still - I used to be a C++ bigot, but I feel the zeal is wearing off; is that love affair over? Confused and bewildered, I surf some other direction, but only to have Sriram Krishnan explain to me that [[http://blogs.msdn.com/sriram/archive/2006/01/15/lisp_is_sin.aspx][Lisp is sin]]. Oh great. I happen to like Lisp a lot - do I really deserve another slap in the face on the same day? But Sriram doesn't really flame us Lisp geeks; quite to the contrary. He is a programmer at Microsoft and obviously strongly impressed by Lisp as a language. His blog entry illustrates how Lisp influenced recent developments in C# - and looks at reasons why Lisp isn't as successful as many people think it should be. Meanwhile, back in the C++ jungle: Those _concepts_ are actually quite clever, and solve an important problem in using C++ templates. In a way, C++ templates use what elsewhere is called [[http://en.wikipedia.org/wiki/Duck_typing][duck typing]]. Why do I say this? Because the types passed to a template are checked implicitly by the template implementation rather than its declaration. If the template implementation says <tt>f = 0</tt> and =f= is a template parameter, then the template assumes that =f= provides an assignment operator - otherwise the code simply won't compile. (The difference to _duck typing_ in its original sense is that we're talking about compile-time checks here, not dynamic function call resolution at run-time.) Hence, templates do not require types to derive from certain classes or interfaces, which is particularly important when using templates for primitive types (such as =int= or =float=). However, when the type check fails, you'll drown in error messages which are cryptic enough to violate the Geneva convention. To fix the error, the user of a template often has to inspect the implementation of the template to understand what's going on. Not exactly what they call encapsulation. Generics in .NET improve on this by specifying constraints explicitly: <verbatim> static void Foobar<T>(IFun<T> fun) where T : IFunny<T> { ... function definition ... } </verbatim> =T= is required to implement =IFunny=. If it doesn't, the compiler will tell you that =T= ain't funny at all, and that's that. No need to dig into the implementation details of the generic function. C++ concepts extend this idea: You can specify pretty arbitrary restrictions on the type. An example from Stroustrup's and Dos Reis' [[http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1886.pdf][paper]]: <verbatim> concept Assignable<typename T, typename U=T> { Var<T> a; Var<const U> b; a = b; }; ;; using this in a template definition: template <typename T, typename U> where Assignable<T, U> ... template definition ... </verbatim> So if =T= and =U= fit into the =Assignable= concept, the compiler will accept them as parameters of the template. This is cute: In true C++ tradition, this provides maximum flexibility and performance, but solves the original problem. Still, that C# code is much easier on the eye... %COMMENT{type="below" nonotify="on"}% --- %STOPINCLUDE%
to top
End of topic
Skip to action links
|
Back to top
Edit
|
Attach image or document
|
Printable version
|
Raw text
|
Refresh
|
More topic actions
Revisions: | r1.1
|
Total page history
|
Backlinks
You are here:
Blog
>
BlogOnSoftware20060117
r1.1 - 17 Feb 2006 - 20:47 -
ClausBrod
to top
Blog
This site
2017
:
12
-
11
-
10
2016
:
10
-
7
-
3
2015
:
11
-
10
-
9
-
4
-
1
2014
:
5
2013
:
9
-
8
-
7
-
6
-
5
2012
:
2
-
10
2011
:
1
-
8
-
9
-
10
-
12
2010
:
11
-
10
-
9
-
4
2009
:
11
-
9
-
8
-
7
-
6
-
5
-
4
-
3
2008
:
5
-
4
-
3
-
1
2007:
12
-
8
-
7
-
6
-
5
-
4
-
3
-
1
2006:
4
-
3
-
2
-
1
2005:
12
-
6
-
5
-
4
2004:
12
-
11
-
10
C++
CoCreate Modeling
COM & .NET
Java
Mac
Lisp
OpenSource
Scripting
Windows
Stuff
Changes
Index
Search
Maintenance
Impressum
Datenschutzerklärung
Home
Webs
Atari
Blog
Claus
CoCreateModeling
Klassentreffen
Main
Sandbox
Sommelier
TWiki
Xplm
Jump:
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback