9front - general discussion about 9front
 help / color / mirror / Atom feed
From: ori@eigenstate.org
To: cinap_lenrek@felloff.net, 9front@9front.org
Subject: Re: [9front] rc: null list in concatenation line numbers
Date: Sun, 25 Oct 2020 18:00:36 -0700	[thread overview]
Message-ID: <91F59916ECF05672C8A64212B2416426@eigenstate.org> (raw)
In-Reply-To: <41990F43512FF80F5598EE88078499ED@felloff.net>

> +		if(f|l != 0){
> +			emitf(Xloc);
> +			emiti(f|l);
> +		}
> 
> you need parentesis there around: f|l

Or I can get rid of the check entirely; if it ever happens,
it's harmless.

> +		/*
> +		 * These are small enough that with a ton of sourcing,
> +		 * overflow is a realistic risk. If we run out of files,
> +		 * set to file 0, which is always '???'
> +		 */
> +		f = (t->file > LFMAX) ? 0 : t->file << LSHIFT;
> +		l = (t->line > LMASK) ? -1 : t->line;
> 
> setting line to -1 also implicitely makes the file all ones...

Oops -- fixed. Good catch.
 
> +	if(i == nlexpath){
> +		if(nlexpath < LFMAX){
> +			lexpath = erealloc(lexpath, (nlexpath + 1)*sizeof(char*));
> +			lexpath[nlexpath] = estrdup(zero);
> +			lexfile = nlexpath++;
> +		}else
> +			lexfile = 0;
> +	}
> 
> might want to use doubling the size for each realloc...

Easy enough to do, but by the time we're sourcing a file,
we're already doing so much other work that doing an extra
realloc probably won't matter. We're currently limiting to
2048 calls over the lifetime of a shell anyways.

Even if that restriction is limited, I'd like to put a
relatively small cap on this, so we're not doing a ton
of O(n) searches -- the only way I can imagine someone
running into the limit is if they generate scripts to
source in a long running script, and an unlimited table
here would be a memory leak.

Still, it's a couple of lines, I'll make the change.

> also wonder if the file can even change in the tree...
> the file would only change when we source a file, no?
> 
> so i wonder if we need to keep track of the file in
> the tree at all, and not just update it at runtime
> in the thread.

You're right, we can just use lexfile directly; the
trees never come from a file other than the one we're
parsing.



  reply	other threads:[~2020-10-26  1:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-16  1:40 ori
2020-10-16  3:43 ` [9front] " Xiao-Yong Jin
2020-10-17  1:47   ` ori
2020-10-16  5:40 ` Iruatã Souza
2020-10-22  1:18 ` ori
2020-10-22 12:11   ` tlaronde
2020-10-25 20:29   ` ori
2020-10-25 23:18     ` cinap_lenrek
2020-10-26  1:00       ` ori [this message]
2020-10-25 23:41     ` cinap_lenrek
2020-10-26  1:33       ` ori
2020-10-26  7:36         ` cinap_lenrek
2020-10-28  3:16           ` ori
2020-10-28  9:50             ` cinap_lenrek
2020-10-28 17:59               ` ori
2020-10-31  1:55               ` ori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=91F59916ECF05672C8A64212B2416426@eigenstate.org \
    --to=ori@eigenstate.org \
    --cc=9front@9front.org \
    --cc=cinap_lenrek@felloff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).