Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!rt.uk.eu.org!feed.xsnews.nl!border-3.ams.xsnews.nl!feeder.xennanews.com!feeder.xennanews.com!nf40.xennanews.com!not-for-mail From: Cecil Westerhof Newsgroups: comp.lang.postscript Subject: Re: Type of element on stack Organization: Decebal Computing References: <87fw4gnafj.fsf@Compaq.site.inet> <87pq3ij9ou.fsf@Compaq.site.inet> X-Homepage: http://www.decebal.nl/ Date: Sat, 17 Nov 2012 14:39:00 +0100 Message-ID: <877gpke4cr.fsf@Compaq.site.inet> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:tu3xk9M0CAqiB2+Tsan2gyLczAk= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@xennanews.com Lines: 38 NNTP-Posting-Host: 84.53.123.169 (84.53.123.169) NNTP-Posting-Date: Sat, 17 Nov 2012 14:59:11 +0100 Xref: csiph.com comp.lang.postscript:1054 Op zaterdag 17 nov 2012 01:19 CET schreef luser droog: > The next cool bit is 'exec'. > 'type' returns an executable name, so you can do type-dispatch with a > dictionary. eg. > > /do { %different things to different types > << > /integertype{1 add} > /booleantype{not} > /realtype{2 exp} > /stringtype{cvr 1 add} >>> 1 index type % x dict x-type > 2 copy known not {pop/default} if > get exec % x' > } def > > Wait. rats. that doesn't use the 'executable' part. > How about... > > /do2 { %coerce input to integer > << > /integertype{} > /realtype{cvi} > /booleantype{{1}{0}ifelse} > /stringtype{cvr round cvi} >>> begin > dup type exec > end > } def I have to look into this, to understand what is happening here, but I gladly will do so. ;-} -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof