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

Integer/Word constants within string constants #26

Open
ratmice opened this issue Sep 10, 2016 · 2 comments
Open

Integer/Word constants within string constants #26

ratmice opened this issue Sep 10, 2016 · 2 comments

Comments

@ratmice
Copy link
Contributor

ratmice commented Sep 10, 2016

It would be nice if in addition to the decimal constant \ddd and \uxxxx
you could just embed an integer constant directly into a string constant prepended by \e.g. #"\0x33"
or something similar to the c syntax '\x33'

The Char.chr function works for this, but it cannot be used in pattern matches

[edit: I suppose just embedding the integer/word constants isn't terribly elegant due to \1x33 etc]

@JohnReppy
Copy link
Contributor

You already have decimal integer constants embedded in strings with "\ddd"; are you asking for
2-byte hexadecimal constants too?

@ratmice
Copy link
Contributor Author

ratmice commented Sep 25, 2016

Yeah, It isn't terribly important as you mention I can (and currently do use "\ddd"), basically the same thing that dwrensha did here:

https://github.com/dwrensha/robotrevolutiondance/blob/master/sml-lib/files/elf/elf.sml
The elf specification defines this by its hex constant:
www.sco.com/developers/gabi/latest/ch4.eheader.html
ELFMAG0 0x7f e_ident[EI_MAG0]

sometimes it would be nice to reflect the constant as defined, rather than doing the conversion, for the benefit of readers comparing the implementation and specification.

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