Hi, I'm trying to add a Lua scripting feature for my external which will allow users to write and run Lua scripts directly in pd as object arguments similar to how [expr] object works.
But the problem is curly brackets are used for table literals (e.g. a = {1, 2, 3}) in Lua, so it is not possible to create tables using this method. I could only use '{' and '}' by editing the patch with a text editor, then reopening the patch in Pd.
I found this code inside canvas_key() function from "g_editor.c" file.
if (keynum == '\' || keynum == '{' || keynum == '}') { post("keycode %d: dropped", (int)keynum); return; }
I would like to know why these 3 characters are not allowed in Pd. Would there be any problem if we remove the above code from Pd? Thanks!
Best regards, Zack
it's because these characters are special in Tcl and Pd currently doesn't try to escape them when sending them to the gui. you can still construct those characters on the Pd side (e.g. sending the ascii value to [list tosymbol]) but you can't type them. I also find this very annoying (you can't type JS, Lua or most other code in Pd) but from what I understood those characters are kept reserved because one day they might be turned into a feature (e.g. using {} for nested lists).
Gesendet: Montag, 14. Mai 2018 um 13:31 Uhr Von: "Zack Lee" cuinjune@gmail.com An: "Miller Puckette" msp@ucsd.edu, "PD List send" pd-list@iem.at Betreff: [PD] Reason for not allowing '{' and '}' in Pd?
Hi, I'm trying to add a Lua scripting feature for my external which will allow users to write and run Lua scripts directly in pd as object arguments similar to how [expr] object works. But the problem is curly brackets are used for table literals (e.g. a = {1, 2, 3}) in Lua, so it is not possible to create tables using this method. I could only use '{' and '}' by editing the patch with a text editor, then reopening the patch in Pd. I found this code inside canvas_key() function from "g_editor.c" file.
if (keynum == '\' || keynum == '{' || keynum == '}') { post("keycode %d: dropped", (int)keynum); return; } I would like to know why these 3 characters are not allowed in Pd. Would there be any problem if we remove the above code from Pd? Thanks! Best regards, Zack _______________________________________________ Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
PS: actually I think there's no reason to reserve them within symbol atoms. it would great to have at least *one* place in Pd where you can just type whatever you want.
Gesendet: Montag, 14. Mai 2018 um 13:43 Uhr Von: "Christof Ressi" christof.ressi@gmx.at An: "Zack Lee" cuinjune@gmail.com Cc: "PD List send" pd-list@iem.at Betreff: Re: [PD] Reason for not allowing '{' and '}' in Pd?
it's because these characters are special in Tcl and Pd currently doesn't try to escape them when sending them to the gui. you can still construct those characters on the Pd side (e.g. sending the ascii value to [list tosymbol]) but you can't type them. I also find this very annoying (you can't type JS, Lua or most other code in Pd) but from what I understood those characters are kept reserved because one day they might be turned into a feature (e.g. using {} for nested lists).
Gesendet: Montag, 14. Mai 2018 um 13:31 Uhr Von: "Zack Lee" cuinjune@gmail.com An: "Miller Puckette" msp@ucsd.edu, "PD List send" pd-list@iem.at Betreff: [PD] Reason for not allowing '{' and '}' in Pd?
Hi, I'm trying to add a Lua scripting feature for my external which will allow users to write and run Lua scripts directly in pd as object arguments similar to how [expr] object works. But the problem is curly brackets are used for table literals (e.g. a = {1, 2, 3}) in Lua, so it is not possible to create tables using this method. I could only use '{' and '}' by editing the patch with a text editor, then reopening the patch in Pd. I found this code inside canvas_key() function from "g_editor.c" file.
if (keynum == '\' || keynum == '{' || keynum == '}') { post("keycode %d: dropped", (int)keynum); return; } I would like to know why these 3 characters are not allowed in Pd. Would there be any problem if we remove the above code from Pd? Thanks! Best regards, Zack _______________________________________________ Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
Thank you so much for your explanation Christof. I really hope to be able to type them in Pd one day.
Regards, Zack Lee
2018-05-14 20:43 GMT+09:00 Christof Ressi christof.ressi@gmx.at:
it's because these characters are special in Tcl and Pd currently doesn't try to escape them when sending them to the gui. you can still construct those characters on the Pd side (e.g. sending the ascii value to [list tosymbol]) but you can't type them. I also find this very annoying (you can't type JS, Lua or most other code in Pd) but from what I understood those characters are kept reserved because one day they might be turned into a feature (e.g. using {} for nested lists).
Gesendet: Montag, 14. Mai 2018 um 13:31 Uhr Von: "Zack Lee" cuinjune@gmail.com An: "Miller Puckette" msp@ucsd.edu, "PD List send" pd-list@iem.at Betreff: [PD] Reason for not allowing '{' and '}' in Pd?
Hi, I'm trying to add a Lua scripting feature for my external which will allow users to write and run Lua scripts directly in pd as object arguments similar to how [expr] object works.
But the problem is curly brackets are used for table literals (e.g. a = {1, 2, 3}) in Lua, so it is not possible to create tables using this method. I could only use '{' and '}' by editing the patch with a text editor, then reopening the patch in Pd.
I found this code inside canvas_key() function from "g_editor.c" file.
if (keynum == '\' || keynum == '{' || keynum == '}') { post("keycode %d: dropped", (int)keynum); return; }
I would like to know why these 3 characters are not allowed in Pd. Would there be any problem if we remove the above code from Pd? Thanks!
Best regards, Zack
_______________________________________________ Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
2018-05-14 8:43 GMT-03:00 Christof Ressi christof.ressi@gmx.at:
it's because these characters are special in Tcl and Pd currently doesn't try to escape them when sending them to the gui. you can still construct those characters on the Pd side (e.g. sending the ascii value to [list tosymbol]) but you can't type them.
sorry, I still don't understand how typing them in a message or comment could be problematic, isn't it just too much of a precaution for no good reason, as it is limiting?
On Mon, May 14, 2018 at 7:31 AM, Zack Lee cuinjune@gmail.com wrote:
Hi, I'm trying to add a Lua scripting feature for my external which will allow users to write and run Lua scripts directly in pd as object arguments similar to how [expr] object works.
Maybe you are no aware that you can right-click a pdlua object and select
'open' to open a text editor. Or maybe this is not what you want...
Martin
I didn't know that was possible in pdlua. Thanks for the info!
Zack
2018-05-14 22:50 GMT+09:00 Martin Peach chakekatzil@gmail.com:
On Mon, May 14, 2018 at 7:31 AM, Zack Lee cuinjune@gmail.com wrote:
Hi, I'm trying to add a Lua scripting feature for my external which will allow users to write and run Lua scripts directly in pd as object arguments similar to how [expr] object works.
Maybe you are no aware that you can right-click a pdlua object and select
'open' to open a text editor. Or maybe this is not what you want...
Martin
On Mon, May 14, 2018 at 4:24 PM, Zack Lee cuinjune@gmail.com wrote:
I didn't know that was possible in pdlua. Thanks for the info!
You could also use something else than { and }, for instance BEGIN and END, and let the external replace BEGIN with { and END with } before sending it to lua. I had the same problem when making the k_cext external.
Thanks for the tip. I'm also considering to use other symbol such as grave accent symbol(`) which I believe is not used in Lua.
Zack
2018-05-14 23:31 GMT+09:00 Kjetil Matheussen k.s.matheussen@gmail.com:
On Mon, May 14, 2018 at 4:24 PM, Zack Lee cuinjune@gmail.com wrote:
I didn't know that was possible in pdlua. Thanks for the info!
You could also use something else than { and }, for instance BEGIN and END, and let the external replace BEGIN with { and END with } before sending it to lua. I had the same problem when making the k_cext external.
On Monday, May 14, 2018, 7:34:24 AM EDT, Zack Lee cuinjune@gmail.com wrote:
Hi, I'm trying to add a Lua scripting feature for my external which will allow users to write and run Lua scripts directly in pd as object arguments similar to how [expr] object works.
I think I merged a patch from Albert for Purr Data to allow curly braces, probably for the case of pdlua. -Jonathan