Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tostring on non-table values adds quotes #1

Open
andrewstarks opened this issue Feb 7, 2013 · 0 comments
Open

tostring on non-table values adds quotes #1

andrewstarks opened this issue Feb 7, 2013 · 0 comments

Comments

@andrewstarks
Copy link

I must acknowledge the guilt I feel for using and benefiting from your work, only to complain about it here. I suck.

RIght now, ml.tstring helpfully adds quotes around values, which is great for visualizing and debugging. You can see exactly where the beginning or ending of input is!

local tostring = require'ml'.tstring
local t = {"3.0","meatballs"}

print(t[1], #t[1], tostring(t[1]), #tostring(t[1]), t[2], tostring(t[2]))
--> 3.0 3   "3.0"   5   meatballs   "meatballs"

When not debugging, I also use tostring for serializing...

local need_string = tostring(t[1])

Later, I might transform back into a number...

print(need_string, tonumber(need_string))
--> "3.0"   nil

Now that I know this, I can use ts = ml.tstring and use lua's version for normal stuff.

It might also be good to copy lua's behavior for non-table values, which would make it easier to inject.

I can imagine a preference for the other way, although I'm fine saying "'"..tostring(v).."'" for the few times that I need to do that.

Bloat is always an option... perhaps ml.tquoted or some such nonsense?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant