Up to Main Index                               Up to Journal for May, 2023

                     JOURNAL FOR SATURDAY 13TH MAY, 2023
______________________________________________________________________________

SUBJECT: PC ordered, some idle thoughts
   DATE: Sat 13 May 17:41:12 BST 2023

After a lot of online research, much hand-wringing and self-justification I
bit the bullet and ordered my new PC. It’s not my first choice, that would
have been an Arm based desktop like ADLINK’s new Ampere Altra developer
platform[1]. Nicer would have been a powerful RISC-V based desktop, if they
even existed. However, I need an Intel based machine for work — got to pay
those pesky bills — so a normal PC it is. One disadvantage of working from
home and providing your own hardware and software is you get to pay for it :(

As the new PC was a customised build I have to wait 2-3 weeks for delivery…

I had and odd, but interesting, discussion about Mere and string handling the
other day. At the moment strings can be concatenated with the addition ‘+’
operator. Strings can also be repeated using the multiply operator ‘*’. For
example:


    >cat test.mr
    println "abc" + "xyz"
    println "abc" * 3
    >mere test.mr
    abcxyz
    abcabcabc
    >


A collogue asked, “what about the operators divide and subtraction?”. Very
good question, but how would it work? For divide we could perform some kind of
chunking on the string. For subtraction we could remove characters, with
positive removing from the right and negative removing from the left. Maybe
something like:


    >cat test.mr
    println literal ("abracadabra" / 3)
    println "banana" - 3
    println "banana" - -2
    >mere test.mr
    []string("abr" "aca" "dab" "ra")
    ban
    nana
    >


I’ve implemented the changes to test how they might work. It seems nice and I
quite like the feature. However, I’m hesitant to commit the changes. The code
just looks very odd and could be confusing:


    >cat test.mr
    println literal ((("abc" + "xyz") * 2 -3 --3) / 3)
    >mere test.mr
    []string("xyz" "abc")
    >


I think a more interesting idea might be how could the basic math operators be
applied to arrays and maps? Addition could concatenate arrays and merge maps.
Multiplication could duplicate the elements in an array, due to keys being
unique this would not work for maps. Divide could split an array or map into
multiple arrays and maps. Subtraction could remove elements from the start or
end of an array or remove keys from a map. The delete built-in already exists,
could subtraction be a better alternative to delete?

For now these are just going to remain idle ideas that might be implemented
later on. I’d be interested in other people’s thoughts: diddymus@wolfmud.org

I also fixed the journal. Last time I forgot to add the index for May which
caused things to look a little odd and broken.

--
Diddymus

  [1] ADLINK’s Ampere Altra developer platform:
      https://www.ipi.wiki/products/ampere-altra-developer-platform


  Up to Main Index                               Up to Journal for May, 2023