Re: Recursive Unions
[Thread Prev] | [Thread Next]
- Subject: Re: Recursive Unions
- From: Ori Bernstein <ori@xxxxxxxxxxxxxx>
- Reply-to: myrddin-dev@xxxxxxxxxxxxxx
- Date: Thu, 16 Aug 2018 17:25:02 -0700
- To: myrddin-dev@xxxxxxxxxxxxxx
- Cc: Yves Cloutier <yves.cloutier@xxxxxxxxx>
On Thu, 16 Aug 2018 20:00:56 -0400 Yves Cloutier <yves.cloutier@xxxxxxxxx> wrote: > Well Ori, that certainly did the job! > > I'm following examples from the book "Programming Language Concepts" by > Peter Sestoft. > > The book uses F# for the implementation of the examples. I thought I would > try to follow along using Myrrdin. > > As a followup question, the F# version of Prim is: > > Prim (string, Expression Expression) > > I used byte[:] here after looking at some examples. looking at the string > package and seeing byte[:] I just assumed is was similar to a C char* or > char[]. > > Is this correct? there is no "string" type? > That's correct, although it isn't a direct equivalent. byte[:] stores the length of the sequence and checks bounds. The APIs uniformly assume that the byte[:] is encoded as utf-8. Also, note that in Myrddin, char is a utf32 code point, and not a byte. This means you would stream through a string character by character using something like: for c : std.bychar(str) frob(c) ;; You *can* index strings, although often it's a bad idea -- and comparing with characters without a cast or decode will give an error: if str[0] == ':' // error if std.decode(str) == ':' // ok You can also iterate by graphemes, thanks to npnth, which means that you get all the combining characters as a unit: for g : std.bygrapheme(str) frob(g) ;; -- Ori Bernstein <ori@xxxxxxxxxxxxxx>
Recursive Unions | Yves Cloutier <yves.cloutier@xxxxxxxxx> |
Re: Recursive Unions | Ori Bernstein <ori@xxxxxxxxxxxxxx> |
Re: Recursive Unions | Yves Cloutier <yves.cloutier@xxxxxxxxx> |
- Prev by Date: Re: Recursive Unions
- Next by Date: [PATCH 1/4] Make timespec/timeval struct members signed to simplify arithmetic.
- Previous by thread: Re: Recursive Unions
- Next by thread: Make-bootstrap failed
- Index(es):