~bubnenkoff

Recent activity

Re: tagged_select_subtype: Assertion `tagged->storage == STORAGE_TAGGED' failed. 2 months ago

From Dmitry B to ~sircmpwn/hare-users

Should be:

`case let s: const str => yield s;`

вт, 26 мар. 2024 г. в 16:22, Dmitry B <bubnenkoff@gmail.com>:
>
> ```
> export fn main() void = {
>    const file = os::open("file.txt")!;
>    const limit_reader = bufio::newscanner(file, 1); //
>
>    for(true) {
>       const lines = match (bufio::scan_line(&limit_reader)!) {
>          case let s: str => yield s;

tagged_select_subtype: Assertion `tagged->storage == STORAGE_TAGGED' failed. 2 months ago

From Dmitry B to ~sircmpwn/hare-users

```
export fn main() void = {
   const file = os::open("file.txt")!;
   const limit_reader = bufio::newscanner(file, 1); //

   for(true) {
      const lines = match (bufio::scan_line(&limit_reader)!) {
         case let s: str => yield s;
         case io::EOF => break;
      };
   };

};
```

Question about proper type initialization 2 months ago

From Dmitry B to ~sircmpwn/hare-users

I have got two questions.
1. Why I am getting an error message in the first case?
2. What is there any difference between `:` and `as`  keywords?
```
   const iter = strings::iter("hello");
   const single_rune: rune = strings::next(&iter); // error:
Initializer is not assignable to binding type

   const single_rune = strings::next(&iter): rune; // ok

   const single_rune = strings::next(&iter) as rune; // ok
```

Re: Need example of using printfln with fmt::mods 2 months ago

From Dmitry B to ~sircmpwn/hare-users

Big thanks!
Last question - what `alignment` do? I tried it, but it did not
aligned nothing to center (or on any other side of console)

пт, 22 мар. 2024 г. в 15:34, Max Schillinger <max@mxsr.de>:
>
> On Fri Mar 22, 2024 at 12:29 PM CET, Dmitry B wrote:
> > Thanks! Could you explain how this line works:
> > `&fmt::mods`
> >
> > It's access to `mods` declared in `fmt` and `&` is ref to it?
> >
> > Why there is no any sign between `&fmt::mods` and `{ ...`?
>

Re: Need example of using printfln with fmt::mods 2 months ago

From Dmitry B to ~sircmpwn/hare-users

Thanks! Could you explain how this line works:
`&fmt::mods`

It's access to `mods` declared in `fmt` and `&` is ref to it?

Why there is no any sign between `&fmt::mods` and `{ ...`?

And how to use align?
fmt::printfln("{%}", 3.1415, &fmt::mods {alignment =
alignment::CENTER, pad = ' ', width = 10, ... })!;

this code do not works

пт, 22 мар. 2024 г. в 14:01, Max Schillinger <max@mxsr.de>:

Need example of using printfln with fmt::mods 2 months ago

From Dmitry B to ~sircmpwn/hare-users

Sorry, but I being confusing.
I can't understand by docs/sources how to use `fmt::printfln` with `fmt::mods`.
I tried different variants but every of them do not compile.
It seems that I only need to do something like this:

```
export fn main() void = {
   fmt::printfln("{%}", fmt::mods = { pad = ' ', width = 10});
};
```

But I am getting an error: `syntax error: expected ';', found ','`

Can't get drain works with stream 2 months ago

From Dmitry B to ~sircmpwn/hare-users

I know that next code could be done in simple way, but I am playing to
try better understand language:

strings::toutf8 - return []u8
memio::fixed - Creates a *stream* from []u8
io::drain - Reads an entire *stream* into a []u8.

```
use fmt;
use io;
use memio;
use strings;

export fn main() void = {

Re: How to make slice from string? 2 months ago

From Dmitry B to ~sircmpwn/hare-users

Oh... it seems that it calculate total size of all arrays of strings,
not single string:
```
export fn join(delim: str, strs: str...) str = {
    let z = 0z;
    for (let i = 0z; i < len(strs); i += 1) {
        z += len(strs[i]);
        if (i + 1 < len(strs)) {
            z += len(delim);
        };
    };
```

вс, 17 мар. 2024 г. в 18:23, Dmitry B <bubnenkoff@gmail.com>:

Re: How to make slice from string? 2 months ago

From Dmitry B to ~sircmpwn/hare-users

Does string store inside any information about its size? Or is it just
u8 sequence?
I am reading source code and seeing strings iterations to get their size.

вс, 17 мар. 2024 г. в 16:01, Drew DeVault <sir@cmpwn.com>:
>
> This is deliberately not possible because, due to the nature of Unicode,
> byte-wise slicing of a string is usually the wrong thing to do in almost
> every language but English. You can use strings::sub, but note that
> this is also going to fall short of what's necessary for a completely
> correct approach to Unicode.

How to make slice from string? 2 months ago

From Dmitry B to ~sircmpwn/hare-users

If the string under the hood is []u8 why can't it be sliced as an array?
```
   const m1: *str = alloc("abc");
   fmt::println(*m1[0..1])!;
```

`error: Cannot slice non-array, non-slice object`