quil icon indicating copy to clipboard operation
quil copied to clipboard

Allow single-quoted strings for PRAGMA

Open notmgsk opened this issue 2 years ago • 4 comments

In Quil-T we make use of PRAGMA FILTER-NODE which expects a json-like string object. For example

PRAGMA FILTER-NODE raw "{'key': 'value', ...}"

The problem is, however, single-quoted strings are not valid JSON, so the above would have to be written

PRAGMA FILTER-NODE raw "{\"key\": \"value\", ...}"

which is awkward and error-prone when writing by-hand.

If we supported using single quotes for the pragma freeform string then the above would become

PRAGMA FILTER-NODE raw '{"key": "value", ...}'

@stylewarning WDYT?

notmgsk avatar Nov 23 '21 22:11 notmgsk

Discussion from Quil call:

  • Robert: Is \ enough of a nuisance? Mark: Yes, it has been.
  • Robert: ' would be nice to reserve for future use;
  • Erik: could possibly use """ or heredoc or so instead
  • Robert, Erik: Multi-line pragmas might be useful

stylewarning avatar Jan 06 '22 20:01 stylewarning

can we use """ for docstrings too? 👼🏽

notmgsk avatar Jan 06 '22 20:01 notmgsk

Bumping this issue. We'd also like to write JSON into DEFFRAME HARDWARE-OBJECT and have it look nice. The backslashes are a bit of a bummer in that case.

caldwellshane avatar Feb 09 '22 00:02 caldwellshane

In fact, would it unreasonable for Quil to have a designator for a JSON string? I feel like we're bumping into genuine contention between Quil and JSON (and potentially other formats) over the " character. Given the description,

HARDWARE-OBJECT is a string indicating the (implementation-specific) hardware object that the frame is associated with.

it seems reasonable to support structured strings describing objects here.

caldwellshane avatar Feb 09 '22 00:02 caldwellshane