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

ly.dom.HandleVars does not handle non-string values #135

Open
chaosmonk1 opened this issue Aug 20, 2019 · 2 comments
Open

ly.dom.HandleVars does not handle non-string values #135

chaosmonk1 opened this issue Aug 20, 2019 · 2 comments
Assignees

Comments

@chaosmonk1
Copy link

>>> import ly.dom
>>> document = ly.dom.Document()
>>> paper = ly.dom.Paper()
>>> paper['ragged-right'] = '##f'
>>> document.append(paper)
>>> printer = ly.dom.Printer()
>>> print(printer.indent(document))
\paper {
  ragged-right = "##f"
}

##f should not be in quotes, because it is a boolean rather than a string. Paper inherits HandleVars, which appears to produce a QuotedString, which for non-string values such booleans isn't correct. Perhaps a more appropriate behavior would be to accept Python booleans and produce Scheme booleans:

>>> paper['ragged-right'] = False
>>> document.append(paper)
>>> printer = ly.dom.Printer()
>>> print(printer.indent(document))
\paper {
  ragged-right = ##f
}
@chaosmonk1
Copy link
Author

My current workaround is to add the assignment as a string,

>>> text = ly.dom.Text('ragged-right = ##f')
>>> paper.append(text)
>>> document.append(paper)
>>> printer = ly.dom.Printer()
>>> print(printer.indent(document))
\paper { ragged-right = ##f }

but it would be nice to be able to assign variables that take scheme values the same way as those that take string values.

@uliska
Copy link
Collaborator

uliska commented Sep 5, 2019

I think you're right, and I also think assigning Python booleans would be the correct way to go. However, since I don't know how that might affect existing use(r)s I suggest to

  • ensure that '##f' will correctly be interpreted as a boolean
  • add the possibility to assign Python booleans

@uliska uliska self-assigned this Sep 5, 2019
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

2 participants