Ich mag das hier:
"PHP is a minor evil perpetrated and created by incompetent amateurs, whereas Perl is a great and insidious evil, perpetrated by skilled but perverted professionals."
"PHP is a minor evil perpetrated and created by incompetent amateurs, whereas Perl is a great and insidious evil, perpetrated by skilled but perverted professionals."
Unbekannter Autor hat geschrieben:The last good thing written in C was Franz Schubert's Symphony No. 9.
Oh, da fehlt aus irgendeinem Grund tatsächlich der Link – eigentlich wollte ich auf diesen Vortrag verweisen: http://bartoszmilewski.wordpress.com/20 ... e-classes/Krishty hat geschrieben:Meinst du hier? :)klickverbot hat geschrieben:Nachdem Alexander vorhin type classes erwähnt hat, hier ein m.E. sehenswertes »post mortem« zu C++0x concepts – Bartosz Milewski vergleicht sie mit bzw. erklärt sie anhand von type classes aus Haskell.
Code: Alles auswählen
object Math {
    def min[T <% Ordered[T]](a: T, b: T) =
        if (a <= b) a else b
    def min[T <% Ordered[T]](seq: T*): T =
        (seq.head /: seq.tail)(min)
}
case class House(numWindows: Int)
object Main extends Application {
    import Math._
    
    implicit def houseOrdering(house: House) = new Ordered[House] {
        override def compare (other: House) = house.numWindows compare other.numWindows
    }
    println("Minimum of integers: " + min(3, 4))
    println("Minimum of houses: " + min(House(4), House(3)))
    println("Minimum of list: " + min(1, 5, -3, 4, 3, -2))
}
Code: Alles auswählen
namespace math
{
    template <typename T>
    const T& min(const T& x, const T& y){return (x<y)?x:y;}
    // oder für Objektliebhaber
    class Object; // Basisklasse für alles
    const Object& min(const Object& x, const Object& y){return (x<y)?x:y;}
} // namespace mathCode: Alles auswählen
writer.writeStartElement(GraphInfoFormat.NavigationGraph.NavigationGraphPage.Metrics.XML_TAG);
writer.writeAttribute(GraphInfoFormat.NavigationGraph.NavigationGraphPage.Metrics.TYPE, GraphInfoFormat.NavigationGraph.NavigationGraphPage.Metrics.Types.TIME);
if (m_timeRegionBitFile != null)
	writer.writeAttribute(GraphInfoFormat.NavigationGraph.NavigationGraphPage.Metrics.REGION_BIT_FILE, m_timeRegionBitFile.toString());
if (m_timeWeightFile != null)
	writer.writeAttribute(GraphInfoFormat.NavigationGraph.NavigationGraphPage.Metrics.WEIGHT_FILE, m_timeWeightFile.toString());
writer.writeAttribute(GraphInfoFormat.NavigationGraph.NavigationGraphPage.Metrics.COUNT, Integer.toString(m_timeCount));
writer.writeEndElement();Code: Alles auswählen
//z.b.
import package.GraphInfoFormat.NavigationGraph.NavigationGraphPage.Metrics;
//...
writer.writeAttribute(Metrics.TYPE, Metrics.Types.TIME);Code: Alles auswählen
	private <DataType extends Page> PageLock<DataType> lockAndFetch(DataType data)
	{
		PageLock<DataType> lock = new PageLock<DataType>(data);
		PageLock<DataType> cleanUpLock = lock;
		
		try
		{
			m_scheduler.fetchPage(data);
			cleanUpLock = null;
			return lock;
		}
		finally
		{
			if (cleanUpLock != null)
				cleanUpLock.release();
		}
	}Code: Alles auswählen
	private <DataType extends Page> PageLock<DataType> lockAndFetch(DataType data)
	{
		PageLock<DataType> lock = new PageLock<DataType>(data);
			
		try
		{
			m_scheduler.fetchPage(data);
			return lock;
		}
		catch(Exception e)
		{
			lock.release();
			throw e; // Error: Exception ist checked.
		}
	}Code: Alles auswählen
// MappedByteBuffer.force() in eigene Methode verpacken, die deren fehlerhafte Exceptionspezifikation um IOException ergänzt
static void throwingForce(MappedByteBuffer buffer) throws IOException
{
   buffer.force();
}
static void forceDownAllTheWayDown(MappedByteBuffer buffer)
{
   boolean success = false;
   
   while(!success)
   {
      try
      {
         throwingForce(buffer);
         success = true;
      }
      catch(IOException e) { }
   }
}Code: Alles auswählen
public static int readInt()
{
	while (true)
		try
		{
			return Integer.parseInt(readLine());
		}
		catch(NumberFormatException e) { }
}Freschheit... immer wenn ich das lese, muss ich an Mich denken!j.klugmann hat geschrieben:.... mit JOGL.