Just playing around with tclpd, pd::strip_selector makes working with the lists nice and easy in Tcl. One thing though: floats are rendered with trailing zeros, so [float 1( is rendered as {float 1.0} in tclpd. tclpd should really use [format %g $arg] to format the floats so that they are the same format as Pd. Pd uses printf("%g", arg).
.hc
----------------------------------------------------------------------------
"Making boring techno music is really easy with modern tools, but with live coding, boring techno is much harder." - Chris McCormick
the t_atom -> Tcl_Obj converasion happens in tcl_class.c using the pdatom_to_tcl function (defined in tcl_typemap.c) since pd has only one numeric type (float), the conversion is as follows:
switch (input->a_type) { [...] case A_FLOAT: { tcl_t_atom[0] = Tcl_NewStringObj("float", -1); tcl_t_atom[1] = Tcl_NewDoubleObj(input->a_w.w_float); break; [...]
so, it gets converted to a [internal] double in tcl (hence, any number appears as a floating point number, integers as well). note that in tcl, in addition to DoubleObj, there are IntObj, LongObj, WideIntObj. would you use those? or what you propose? actually there is no formatting involved, 1.0 it's just how a float appears by default in tcl e.g. when you print it.
Il 12/11/2011 06:27, Hans-Christoph Steiner ha scritto:
Just playing around with tclpd, pd::strip_selector makes working with the lists nice and easy in Tcl. One thing though: floats are rendered with trailing zeros, so [float 1( is rendered as {float 1.0} in tclpd. tclpd should really use [format %g $arg] to format the floats so that they are the same format as Pd. Pd uses printf("%g", arg).
.hc
"Making boring techno music is really easy with modern tools, but with live coding, boring techno is much harder." - Chris McCormick
I'm interpretting lists as filenames with spaces in it. Its a hack, I know, but it works well for the most part. So something like:
[this contains 20 rows.csv(
Would give me "this contains 20.0 rows.csv" in tclpd. Perhaps just the proc pd::strip_selectors could do the %g formatting. That's what I'm using in tclfile/exists currently, and would like to do it in the whole library.
.hc
On Nov 12, 2011, at 5:45 PM, mescalinum@gmail.com wrote:
the t_atom -> Tcl_Obj converasion happens in tcl_class.c using the pdatom_to_tcl function (defined in tcl_typemap.c) since pd has only one numeric type (float), the conversion is as follows:
switch (input->a_type) { [...] case A_FLOAT: { tcl_t_atom[0] = Tcl_NewStringObj("float", -1); tcl_t_atom[1] = Tcl_NewDoubleObj(input->a_w.w_float); break; [...]
so, it gets converted to a [internal] double in tcl (hence, any number appears as a floating point number, integers as well). note that in tcl, in addition to DoubleObj, there are IntObj, LongObj, WideIntObj. would you use those? or what you propose? actually there is no formatting involved, 1.0 it's just how a float appears by default in tcl e.g. when you print it.
Il 12/11/2011 06:27, Hans-Christoph Steiner ha scritto:
Just playing around with tclpd, pd::strip_selector makes working with the lists nice and easy in Tcl. One thing though: floats are rendered with trailing zeros, so [float 1( is rendered as {float 1.0} in tclpd. tclpd should really use [format %g $arg] to format the floats so that they are the same format as Pd. Pd uses printf("%g", arg).
.hc
"Making boring techno music is really easy with modern tools, but with live coding, boring techno is much harder." - Chris McCormick
----------------------------------------------------------------------------
“We must become the change we want to see. - Mahatma Gandhi