<txp:article status="sticky" limit=1 /> ->  Textpattern Warning: Die Werte für Attribute müssen in Hochkommata eingeschlossen werden  on line 916
textpattern/lib/txplib_misc.php:916 trigger_error()
textpattern/publish.php:1090 splat()
textpattern/publish.php:1012 processTags()
textpattern/publish.php:496 parse()
index.php:33 textpattern()
Peterpedia-Flash: Postfix type declarations
Übersicht Peterpedia lesen What's up Peterpedia? Administration Suche

Postfix type declarations · Apr 2, 08:00 von stargaming

Der beste Aprilscherz (abgesehen von unserem und bereits erwähnten) ist Georg Brandls Vorschlag der Unicode Postfix type declarations.

Nachtrag: Haah, Python on Planes.

Ausschnitte

Python has long suffered from the lack of explicit type declarations. [...]
Unicode makes it possible to express much more with much less characters, which is in accordance with the Zen (“Readability counts.”). Additionally, it eliminates the need for a separate type declaration statement, and last but not least, it makes Python measure up to Perl 6, which already uses Unicode for its operators. [...]

When the type declaration mode is in operation, the grammar is changed so that each NAME must consist of two parts: a name and a type declarator, which is exactly one Unicode character.
The declarator uniquely specifies the type of the name, and if it occurs on the left hand side of an expression, this type is enforced: an InquisitionError exception is raised if the returned type doesn’t match the declared type. [...]

The mapping between types and declarators is not static. It can be completely customized by the programmer, but for convenience there are some predefined mappings for some built-in types:

object (REPLACEMENT CHARACTER)
int (DOUBLE-STRUCK CAPITAL N)
float (ESTIMATED SYMBOL)
bool (CHECK MARK)
tuple (PARENTHESIZED LATIN SMALL LETTER T)
dict (DOUBLE-ENDED MULTIMAP)
set (EMPTY SET)
function ƛ (LATIN SMALL LETTER LAMBDA WITH STROKE)

The declarator for the None type is a zero-width space.
These characters should be obvious and easy to remember and type for every programmer. [...]

Since even in our modern, globalized world there are still some old-fashioned rebels who can’t or don’t want to use Unicode in their source code, and since Python is a forgiving language, a fallback is provided for those:
Instead of the single Unicode character, they can type name${UNICODE NAME OF THE DECLARATOR}$. [...]

The encoding in which the code is written is read from a standard coding cookie. There will also be an autodetection mechanism, invoked by from __future__ import encoding_hell.

Artikel bearbeiten