gnark icon indicating copy to clipboard operation
gnark copied to clipboard

feat: add format specifiers for `api.Println` or implement `api.Printf`

Open George551556 opened this issue 1 year ago • 3 comments

To be precise, I think you can add a func like api.Printf("this is my var %fv. ", circuit.x), and hope it have the same performance with fmt.Printf()

func (circuit *Circuit) Define(api frontend.API) error{
    api.Printf("this is my var %fv. ", circuit.x)
}
go
cmd output: this is my var 2

George551556 avatar Aug 07 '24 01:08 George551556

It could be useful - I think we could have different formatting options:

  • hex
  • int
  • small integer - if value is small when considered as a negative, then print that instead
  • coefficient ID
  • variable ID

ivokub avatar Aug 07 '24 06:08 ivokub

@ivokub In addition to api.Println(), it's possible to provide a new API api.Fmt() that feeds the printing content to a string?

zliucd avatar Sep 02 '24 11:09 zliucd

It is possible, but we currently don't have it on the roadmap. I think it could be a suitable task for external contribution though.

ivokub avatar Sep 03 '24 12:09 ivokub