unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* [ANN] guile-msgpack: MessagePack for GNU Guile (+ help needed)
@ 2018-09-20 11:24 Aleksandar Sandic
  0 siblings, 0 replies; 8+ messages in thread
From: Aleksandar Sandic @ 2018-09-20 11:24 UTC (permalink / raw)
  To: guile-user

Oops, wrong email address, please don't reply to this one, I'll ask the admins 
to delete it...





^ permalink raw reply	[flat|nested] 8+ messages in thread
* [ANN] guile-msgpack: MessagePack for GNU Guile (+ help needed)
@ 2018-09-20 11:15 Aleksandar Sandic
  0 siblings, 0 replies; 8+ messages in thread
From: Aleksandar Sandic @ 2018-09-20 11:15 UTC (permalink / raw)
  To: guile-user

I have renamed `pack!` and  `unpack!` to `pack-to` and `unpack-from`, 
following the advice about not using the exclamation mark suffix with side 
effects regarding ports. I have also changed the order of arguments so the 
first argument to `pack-to` is the port and the rest is an arbitrary number of 
objects to pack.

    (pack-to (current-output-port) 2 3 "hello")

I think this also rolls better off the tongue: pack to the current output port 
2, 3 and "hello".





^ permalink raw reply	[flat|nested] 8+ messages in thread
* [ANN] guile-msgpack: MessagePack for GNU Guile (+ help needed)
@ 2018-09-19 12:33 HiPhish
  2018-09-19 13:29 ` Thompson, David
  2018-09-19 14:12 ` John Cowan
  0 siblings, 2 replies; 8+ messages in thread
From: HiPhish @ 2018-09-19 12:33 UTC (permalink / raw)
  To: guile-user

Hello Schemers,

I am pleased to announce to the public a project I have been working on for a 
while: an implementation of the MessagePack[1] data serialization format for 
GNU Guile.

https://gitlab.com/HiPhish/guile-msgpack


## What is MessagePack ##

MessagePack is a specification for how to turn data into byte and vice-versa. 
Think of it like JSON, except instead of human readability it stresses speed 
and size efficiency. The format is binary and well suited for data exchange 
between processes. It also forms the basis of the MessagePack RPC protocol[2].


## About the Guile implementation ##

My implementation is written in pure Guile Scheme, so it should work out of 
the box. You can try it out without installing anything. Just clone the repo 
and give it a try:

    $ guile -L .
    
    scheme@(guile-user)> ,use (msgpack)
    scheme@(guile-user)> (pack "hello" 1337 #t)
    $1 = #vu8(165 104 101 108 108 111 205 5 57 195)

As you can see, the three objects passed to the `pack` procedure have been 
turned into one big bytevector. We could now unpack this bytevector again, 
write it to a file, or send if off to a port. Since using MessagePack with 
ports is a frequent task there is also a `pack!` procedure which takes in a 
port to pack to as well.

    (define hodgepodge (vector 1 2 '#(3 #t) "foo"))
    (pack! hodgepodge (current-output-port))

To get our object back we `unpack` it:

    (unpack #vu8(#xA5 #x68 #x65 #x6C #x6C #x6F))  ; Returns "hello"
    (unpack! (current-input-port))

The readme goes into more detail and the (Texinfo) manual has the complete 
documentation. Building it is simple enough with the included makefile.


## What's next? ##

Next is your feedback! Once the library has settled down I would like to make 
it into a Guix package. From there I can then start building a MessagePack RPC 
implementation and finally a Neovim client which will allow people to write 
plugins for Neovim in GNU Guile. (yes, Vim plugins written in Lisp, who would 
have thought?)


## Help needed ##

This is my first time making a full project in Guile, so I would appreciate it 
if someone with more experience could look over my code. I have written down 
some things I could think of in the todo file. In particular I would like to 
know:

How much is portability a concern? I know Guile implements *some* or r6rs, but 
I wasn't paying much attention to that. Is it something worth considering or 
should I just treat Guile as its own language that just so happens to be based 
on Scheme?

The extension type `ext` (msgpack/ext.scm) is a pair of a signed 8-bit integer 
and a bytevector. The constructor does not enforce this condition, the two 
slots can be really anything. What it the proper way of enforcing this in 
Guile? I know Common Lisp has type declarations and Racket has contracts, but 
what does Guile have?

The `pack` procedure takes any number of objects and packs them into a large 
bytevector. However, the `unpack` procedure only returns the first object it 
unpacks. Is there a way of making it unpack as many as it can? I thought of 
`values`, but you would need to know the number of values in advance. Also the 
caller would have to know in advance how many objects he is going to get 
unpacked.

As I said, there is more in the todo file, but the other questions are under 
the hood, not user-visible.


## The inevitable panhandling ##

I don't want to go into this too much, because no one likes to read it, but if 
you like my MessagePack implementation I would really appreciate if you could 
spare some cash. Links are in the readme; at the moment I only have Liberapay 
set up, if anyone can recommend me a service for one-time donations that would 
be cool. All the services I could find were about fundraising for charity and 
stuff, not what I was looking for.


_______________________________________________________________________________
[1] https://msgpack.org/
[2] https://github.com/msgpack-rpc/msgpack-rpc





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-09-20 11:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-20 11:24 [ANN] guile-msgpack: MessagePack for GNU Guile (+ help needed) Aleksandar Sandic
  -- strict thread matches above, loose matches on Subject: below --
2018-09-20 11:15 Aleksandar Sandic
2018-09-19 12:33 HiPhish
2018-09-19 13:29 ` Thompson, David
2018-09-19 14:06   ` HiPhish
2018-09-19 14:12 ` John Cowan
2018-09-19 23:32   ` HiPhish
2018-09-20  1:44     ` John Cowan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).