ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> tcl-core
tcl-core
Re: [TCLCORE] The end for Tcl_PrintDouble in Tk?
by Jeff Hobbs other posts by this author
May 19 2009 8:41PM messages near this date
Re: [TCLCORE] The end for Tcl_PrintDouble in Tk? | [TCLCORE] Tk Aqua future on Tiger
On 19/05/2009 8:08 PM, Michael Kirkham wrote:
>  This may not be a direct opinion as to your specific question, but both 
>  of those look (IMHO) like throwbacks from the days before objects. 
>  Assuming the precision change isn't an issue, why wouldn't you use...
>  
>       EntryVisibleRange(entryPtr, &first, &last);
>       objPtr = Tcl_DuplicateObj(entryPtr->scrollCmd);
>       Tcl_ListObjAppendElement(interp, objPtr, Tcl_NewDoubleObj(first));
>       Tcl_ListObjAppendElement(interp, objPtr, Tcl_NewDoubleObj(last));
>       code = Tcl_EvalObjEx(interp, objPtr, TCL_EVAL_GLOBAL|TCL_EVAL_DIRECT);
>  ...?

This is a very good question with a very good answer.

For the long version see the very recent discussion on tcl chat logs 
again, but the short of it is this works for command prefixes, where you 
might do:
	-scrollcmd [list myCommand opt1 opt2]
or	-scrollcmd [list $widget xview]

but it would break for the (currently legal) script prefix case of:
	-scrollcmd "puts foo ; # ignore the rest"

There is relatively strong agreement amongst Tk dev that Tk 9 should 
disallow the latter (if we can't sneak it in earlier ...).

Jeff

>  On Tue, 19 May 2009, Jeff Hobbs wrote:
>  
> > Date: Tue, 19 May 2009 19:57:06 -0700
> > From: Jeff Hobbs <jeffh@[...].com>
> > To: Tcl Core List <tcl-core@[...].net>
> > Subject: [TCLCORE] The end for Tcl_PrintDouble in Tk?
> >
> > In looking into the best solution for 2790615
> > https://sourceforge.net/tracker/?func=detail&atid=112997&aid=2790615&group_id=12997 
> >
> > Don noted that Tcl_ObjPrintf (added in 8.5) or Tcl_AppendFormatToObj
> > would be good alternatives to the coding changes I was using.
> >
> > This would change, eg tkEntry.c:EntryUpdateScrollbar from (partial):
> >
> >     EntryVisibleRange(entryPtr, &first, &last);
> >     Tcl_PrintDouble(NULL, first, firstStr);
> >     Tcl_PrintDouble(NULL, last, lastStr);
> >     objPtr = Tcl_NewStringObj(entryPtr->scrollCmd, -1);
> >     Tcl_IncrRefCount(objPtr);
> >     Tcl_AppendStringsToObj(objPtr, " ", firstStr, " ", lastStr, NULL);
> >     code = Tcl_EvalObjEx(interp, objPtr, 
> > TCL_EVAL_GLOBAL|TCL_EVAL_DIRECT);
> > ...
> >
> > to:
> >
> >     EntryVisibleRange(entryPtr, &first, &last);
> >     objPtr = Tcl_ObjPrintf("%s %f %f", entryPtr->scrollCmd, first, last);
> >     Tcl_IncrRefCount(objPtr);
> >     code = Tcl_EvalObjEx(interp, objPtr, 
> > TCL_EVAL_GLOBAL|TCL_EVAL_DIRECT);
> > ...
> >
> > the problem is that Tcl_PrintDouble takes into account the (now
> > deprecated) tcl_precision variable.  The above causes errors in the test
> > suite for where "scrollCmd 0.0 1.0" was expected, it now receives
> > "scrollCmd 0.000000 1.000000".  These are error cases that have exact
> > expectations on the string output.
> >
> > Most uses of the ~25 Tcl_PrintDoubles in Tk relate to scrolling, and
> > that the values passed are moved through Tcl_PD, whereas the above goes
> > to the raw sprintf handling of %f.
> >
> > The Tcl_PDs exist from the time that we sanitized everything and EIAS
> > was always true in Tk.  Would changing this be considered a compat
> > issue, or just clean-up?
> >
> > Jeff

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
_______________________________________________
Tcl-Core mailing list
Tcl-Core@[...].net
https://lists.sourceforge.net/lists/listinfo/tcl-core
Thread:
Jeff Hobbs
Joe English
dgp
Jeff Hobbs
Joe English
Michael Kirkham
Joe English
Jeff Hobbs

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved