jwiegley / emacs-async

Simple library for asynchronous processing in Emacs
GNU General Public License v3.0
836 stars 68 forks source link

async-start returns hash tables as lists #164

Open jinnovation opened 1 year ago

jinnovation commented 1 year ago

It appears that any value of START-FUNC for async-start that returns a hash table gets forwarded to FINISH-FUNC as a list. See repro below:

(async-start (lambda () (ht)) (lambda (res) (message "%s" (type-of res)))) ;; "cons"

(async-start (lambda () (ht)) (lambda (res) (message "%s" res))) ;; (hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data nil)

Is this a known limitation?

Fuco1 commented 1 year ago

There is some code stripping out the # because of some issues in #145 . I don't fully understand why.

In newer Emacs, the hashtable syntax is actually

s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data nil)

(notice the s) and it is readable, so we should allow that.

@thierryvolpiatto Why don't we allow reading back propertized lists, they are supported by read1.

| #("test" 0 1 (tag #("WORK" 0 4 (inherited t))))

(read (current-buffer)) produces the same thing back.

The only issue with this is passing things like frames, markers, buffers which have the unreadable syntax #<. We can add a method async-serialize and crawl the objects ourselves and try to serialize them somehow... but they are basically unrestorable from one Emacs process to another, so could also just be replaced by some :async-impossible value instead.

I'd very much like to send hash-tables back and forth so I'll look into this.

thierryvolpiatto commented 1 year ago

Matus Goljer @.***> writes:

@thierryvolpiatto Why don't we allow reading back propertized lists, they are supported by read1.

| #("test" 0 1 (tag #("WORK" 0 4 (inherited t))))

(read (current-buffer)) produces the same thing back.

The only issue with this is passing things like frames, markers, buffers which have the unreadable syntax #<.

Exactly, in #145 we have text with properties containing themselves markers (see text properties in an org agenda buffer).

We can add a method async-serialize and crawl the objects ourselves and try to serialize them somehow... but they are basically unrestorable from one Emacs process to another, so could also just be replaced by some :async-impossible value instead.

I'd very much like to send hash-tables back and forth so I'll look into this.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.*Message ID: @.***>

-- Thierry