Mailing List Archive

Elevator pitch - independent symbol spaces
Hi porters,

I tried to write down proposal for generic independent symbol spaces, not
only for Oshun's
data contract checks but little bit more abstract / generic so it can
handle for example attribute
as well.

This is first of three intertwined ideas related to Oshun.

Shortly:
- add support to store non-core symbols in current structures (GV)
- add C API to register new symbol spaces (including use of plugin grammars
for symbol values)
- add generic `declare` statement and `declared` expression
- first try on import mechanism

Full spec is available at
https://github.com/happy-barney/perl-wish-list/blob/master/independent-symbol-spaces/README.md

Best regards,
Brano
Re: Elevator pitch - independent symbol spaces [ In reply to ]
On Mon, 25 Sep 2023 13:59:18 +0200
Branislav Zahradník <happy.barney@gmail.com> wrote:

> Hi porters,
>
> I tried to write down proposal for generic independent symbol spaces,
> not only for Oshun's
> data contract checks but little bit more abstract / generic so it can
> handle for example attribute
> as well.

Independent namespaces sound good at first glance, yes.. but see below.

> This is first of three intertwined ideas related to Oshun.
>
> Shortly:
> - add support to store non-core symbols in current structures (GV)

Ah - that's where I'm less convinced.

GVs are how the (global) symbol table is implemented. Which means these
namespaces are global package-shaped, rather than being lexical.

For something like constraint check names for Oshun, or similar other
kinds of ideas, I'd be more keen to see them /lexically/ available
rather than stuffed into the symbol table.

--
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/
Re: Elevator pitch - independent symbol spaces [ In reply to ]
On Mon, 25 Sept 2023 at 14:21, Paul "LeoNerd" Evans <leonerd@leonerd.org.uk>
wrote:

> On Mon, 25 Sep 2023 13:59:18 +0200
> Branislav Zahradník <happy.barney@gmail.com> wrote:
>
> > Hi porters,
> >
> > I tried to write down proposal for generic independent symbol spaces,
> > not only for Oshun's
> > data contract checks but little bit more abstract / generic so it can
> > handle for example attribute
> > as well.
>
> Independent namespaces sound good at first glance, yes.. but see below.
>

Thanks, I was already running in circles.


>
> > This is first of three intertwined ideas related to Oshun.
> >
> > Shortly:
> > - add support to store non-core symbols in current structures (GV)
>
> Ah - that's where I'm less convinced.
>
> GVs are how the (global) symbol table is implemented. Which means these
> namespaces are global package-shaped, rather than being lexical.
>
> For something like constraint check names for Oshun, or similar other
> kinds of ideas, I'd be more keen to see them /lexically/ available
> rather than stuffed into the symbol table.
>

Independent symbol spaces are meant to be abstract framework for any kind of
symbols, not only Oshun. Even there there is space for both kind of symbols.

As I wrote it down in Open questions, I don't know (yet) how pad works so
that
that's why lexical part is missing.



>
> --
> Paul "LeoNerd" Evans
>
> leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS
> http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/
>
Re: Elevator pitch - independent symbol spaces [ In reply to ]
Based on discussion on IRC, let's restart this idea with decomposing it
here.

First question: do we want independent symbol spaces?
- I assume answer to this is "yes"

What scope of symbols declared in independent symbol space should be
supported?

a) global ... example of such symbol is attribute `lvalue` or built-in
functions (eg: say)
b) package ... importable/exportable, addressable using full qualification
c) lexical
d) localized

global scope may be restricted to internal use only
What it should be used for:
- built-in attributes (like lvalue, method, ...)
- built-in data contracts (eg: Int)

Brano
Re: Elevator pitch - independent symbol spaces [ In reply to ]
On Mon, Oct 02, 2023 at 07:08:52PM +0200, Branislav Zahradn?k wrote:
> Based on discussion on IRC, let's restart this idea with decomposing it
> here.
>
> First question: do we want independent symbol spaces?
> - I assume answer to this is "yes"

I have no idea what "independent symbol spaces" are, or why they might be
desirable. So my answer to the first question is "don't know know; please
explain in more detail".


--
Never do today what you can put off till tomorrow.
Re: Elevator pitch - independent symbol spaces [ In reply to ]
> I have no idea what "independent symbol spaces" are, or why they might be
> desirable. So my answer to the first question is "don't know know; please
> explain in more detail".
>

Thanks for reaction.

Simple answer is that independent symbol space is a non-colliding name
space.

Technically even now Perl has few independent symbol spaces:
- scalar variables
- array variables
- hash variables
- subs
- globs
- formats
- attributes (those hard coded - eg lvalue)

Independent symbol spaces as mentioned in this idea is e mechanism to allow
declaration of such non-colliding symbol spaces
by extensions (or by Perl itself).

Independent symbol spaces should provide common mechanism:
- managing errors and warnings (undefined symbol, redefine symbol)
- managing scope (our / my / local / state / without modifier)
- import / export symbols
- attach behaviour represented by those symbols to current workflow (eg:
attach data contract to variable)

Idea started with Oshun, where symbols (barewords) should not conflict with
existing symbols (ie, you can have data contract named 'int')


>
>
>
> --
> Never do today what you can put off till tomorrow.
>
Re: Elevator pitch - independent symbol spaces [ In reply to ]
I will add examples to that to further help understanding.

The "independent symbol spaces" means you can have multiple things all named
"foo" that can be distinguished from each other by context.

So for example:

sub foo { ... }

my $foo;

Here we have two "foo" that can be distinguished because they have different
symbol spaces.

The proposal involves adding more synbol spaces that can be distinguished
mutually from those and each other.

-- Darren Duncan

On 2023-10-06 6:28 a.m., Branislav Zahradník wrote:
>
> I have no idea what "independent symbol spaces" are, or why they might be
> desirable. So my answer to the first question is "don't know know; please
> explain in more detail".
>
>
> Thanks for reaction.
>
> Simple answer is that independent symbol space is a non-colliding name space.
>
> Technically even now Perl has few independent symbol spaces:
> - scalar variables
> - array variables
> - hash variables
> - subs
> - globs
> - formats
> - attributes (those hard coded - eg lvalue)
>
> Independent symbol spaces as mentioned in this idea is e mechanism to allow
> declaration of such non-colliding symbol spaces
> by extensions (or by Perl itself).
>
> Independent symbol spaces should provide common mechanism:
> - managing errors and warnings (undefined symbol, redefine symbol)
> - managing scope (our / my / local / state / without modifier)
> - import / export symbols
> - attach behaviour represented by those symbols to current workflow (eg: attach
> data contract to variable)
>
> Idea started with Oshun, where symbols (barewords) should not conflict with
> existing symbols (ie, you can have data contract named 'int')
>
>
>
> --
> Never do today what you can put off till tomorrow.
>
Re: Elevator pitch - independent symbol spaces [ In reply to ]
On Fri, 6 Oct 2023 at 21:39, Darren Duncan <darren@darrenduncan.net> wrote:

> I will add examples to that to further help understanding.
>
> The "independent symbol spaces" means you can have multiple things all
> named
> "foo" that can be distinguished from each other by context.
>
> So for example:
>
> sub foo { ... }
>
> my $foo;
>
> Here we have two "foo" that can be distinguished because they have
> different
> symbol spaces.
>
> The proposal involves adding more synbol spaces that can be distinguished
> mutually from those and each other.
>
>
Thanks for an example, Darren.

It's about adding more internal symbol spaces as well as adding more
external symbol spaces (modules)

Internal symbol spaces I have on my mind:
- attributes
- data contract names (eg: Type::Tiny, Oshun, ...)
- named regexps
- smartmatch rules (aka healing smartmatch - greatly inspired by one
Syntax::Keyword::Match discussion here)
- constants

Modules where having their own symbol space make sense:
- Context::Singleton
- Dancer2

Best regards,
Brano
Re: Elevator pitch - independent symbol spaces [ In reply to ]
On Tue, Oct 10, 2023 at 10:00:18AM +0200, Branislav Zahradn?k wrote:
> It's about adding more internal symbol spaces as well as adding more
> external symbol spaces (modules)
>
> Internal symbol spaces I have on my mind:
> - attributes
> - data contract names (eg: Type::Tiny, Oshun, ...)
> - named regexps
> - smartmatch rules (aka healing smartmatch - greatly inspired by one
> Syntax::Keyword::Match discussion here)
> - constants
>
> Modules where having their own symbol space make sense:
> - Context::Singleton
> - Dancer2

I still don't really understand.

Perl's existing namespaces are intimately tied to the lexer and parser,
and their current state. For example, when the compiler sees '$foo', it
searches through the chain of pads currently in scope for a '$foo' entry;
if none are found, it searches for a 'foo' entry in the current stash,
then looks for a scalar entry in that typeglob.

How would these new namespaces be used? What syntax and mechanisms would
be in place to make use of these new namespaces?

--
Justice is when you get what you deserve.
Law is when you get what you pay for.
Re: Elevator pitch - independent symbol spaces [ In reply to ]
On Thu, 12 Oct 2023 at 14:07, Dave Mitchell <davem@iabyn.com> wrote:

> On Tue, Oct 10, 2023 at 10:00:18AM +0200, Branislav Zahradník wrote:
> > It's about adding more internal symbol spaces as well as adding more
> > external symbol spaces (modules)
> >
> > Internal symbol spaces I have on my mind:
> > - attributes
> > - data contract names (eg: Type::Tiny, Oshun, ...)
> > - named regexps
> > - smartmatch rules (aka healing smartmatch - greatly inspired by one
> > Syntax::Keyword::Match discussion here)
> > - constants
> >
> > Modules where having their own symbol space make sense:
> > - Context::Singleton
> > - Dancer2
>
> I still don't really understand.
>
> Perl's existing namespaces are intimately tied to the lexer and parser,
> and their current state. For example, when the compiler sees '$foo', it
> searches through the chain of pads currently in scope for a '$foo' entry;
> if none are found, it searches for a 'foo' entry in the current stash,
> then looks for a scalar entry in that typeglob.
>

> How would these new namespaces be used? What syntax and mechanisms would
> be in place to make use of these new namespaces?
>

One question is missing: how to import/export these new symbols ?

Very short answer:

- typeglob will be changed to contain (dynamic) array for symbols in
particular symbol space
eg (demonstration of approach):
#define GvCV(gv) ((CV*)GvGP(gv)->gp_cv)
will be changed to:
#define GvCV(gv) ((CV*)GvGP(gv)->gp_symbols[SYMBOL_SPACE_CV])

- pad - that I don't know yet, that's open question

- lexer
- every usage of external symbol space is prefixed by distinct token
- new statement: declare
- new expression: declared
- new prototype similar to &;@ ... $<Symbol::Space::Identifier>
- symbol space behaviour will be attached to context via attributes
- symbol spaces provide their own pluggable grammar to parse their
declaration

Mental model:
sigils in perl already behaves like symbol space switch, for example:
$foo = new value;
can be treated as
declared scalar foo = new value;

More at
https://github.com/happy-barney/perl-wish-list/tree/master/independent-symbol-spaces
(it's split into multiple pages)



> --
> Justice is when you get what you deserve.
> Law is when you get what you pay for.
>
Re: Elevator pitch - independent symbol spaces [ In reply to ]
On Thu, 12 Oct 2023 at 15:50, Branislav Zahradník <happy.barney@gmail.com>
wrote:

>
>
> On Thu, 12 Oct 2023 at 14:07, Dave Mitchell <davem@iabyn.com> wrote:
>
>> On Tue, Oct 10, 2023 at 10:00:18AM +0200, Branislav Zahradník wrote:
>> > It's about adding more internal symbol spaces as well as adding more
>> > external symbol spaces (modules)
>> >
>> > Internal symbol spaces I have on my mind:
>> > - attributes
>> > - data contract names (eg: Type::Tiny, Oshun, ...)
>> > - named regexps
>> > - smartmatch rules (aka healing smartmatch - greatly inspired by one
>> > Syntax::Keyword::Match discussion here)
>> > - constants
>> >
>> > Modules where having their own symbol space make sense:
>> > - Context::Singleton
>> > - Dancer2
>>
>> I still don't really understand.
>>
>> Perl's existing namespaces are intimately tied to the lexer and parser,
>> and their current state. For example, when the compiler sees '$foo', it
>> searches through the chain of pads currently in scope for a '$foo' entry;
>> if none are found, it searches for a 'foo' entry in the current stash,
>> then looks for a scalar entry in that typeglob.
>>
>
>> How would these new namespaces be used? What syntax and mechanisms would
>> be in place to make use of these new namespaces?
>>
>
> One question is missing: how to import/export these new symbols ?
>
> Very short answer:
>
> - typeglob will be changed to contain (dynamic) array for symbols in
> particular symbol space
> eg (demonstration of approach):
> #define GvCV(gv) ((CV*)GvGP(gv)->gp_cv)
> will be changed to:
> #define GvCV(gv) ((CV*)GvGP(gv)->gp_symbols[SYMBOL_SPACE_CV])
>
> - pad - that I don't know yet, that's open question
>

So regarding pad, would it be easier to understand, if aforementioned
lookup will be changed into:

lookup_symbol ("$", "foo")

Pads should be changed from simple single-key to multi-key.

Simple fake sigil may help (assuming external symbol_space_id will be at
least 9-bit number)
pad_name = chr (symbol_space_id) . name_without_sigil;

though it will be imho better to use compound keys and unify representation
of pad and typeglob


> - lexer
> - every usage of external symbol space is prefixed by distinct token
> - new statement: declare
> - new expression: declared
> - new prototype similar to &;@ ... $<Symbol::Space::Identifier>
> - symbol space behaviour will be attached to context via attributes
> - symbol spaces provide their own pluggable grammar to parse their
> declaration
>
> Mental model:
> sigils in perl already behaves like symbol space switch, for example:
> $foo = new value;
> can be treated as
> declared scalar foo = new value;
>
> More at
> https://github.com/happy-barney/perl-wish-list/tree/master/independent-symbol-spaces
> (it's split into multiple pages)
>
>
>
>> --
>> Justice is when you get what you deserve.
>> Law is when you get what you pay for.
>>
>
Re: Elevator pitch - independent symbol spaces [ In reply to ]
On Thu, Oct 12, 2023 at 03:50:53PM +0200, Branislav Zahradn?k wrote:
> On Thu, 12 Oct 2023 at 14:07, Dave Mitchell <davem@iabyn.com> wrote:
> >
> > I still don't really understand.
> >
> > Perl's existing namespaces are intimately tied to the lexer and parser,
> > and their current state. For example, when the compiler sees '$foo', it
> > searches through the chain of pads currently in scope for a '$foo' entry;
> > if none are found, it searches for a 'foo' entry in the current stash,
> > then looks for a scalar entry in that typeglob.
> >
>
> > How would these new namespaces be used? What syntax and mechanisms would
> > be in place to make use of these new namespaces?
> >
>
> One question is missing: how to import/export these new symbols ?
>
> Very short answer:
>
> - typeglob will be changed to contain (dynamic) array for symbols in
> particular symbol space
> eg (demonstration of approach):
> #define GvCV(gv) ((CV*)GvGP(gv)->gp_cv)
> will be changed to:
> #define GvCV(gv) ((CV*)GvGP(gv)->gp_symbols[SYMBOL_SPACE_CV])
>
> - pad - that I don't know yet, that's open question
>
> - lexer
> - every usage of external symbol space is prefixed by distinct token
> - new statement: declare
> - new expression: declared
> - new prototype similar to &;@ ... $<Symbol::Space::Identifier>
> - symbol space behaviour will be attached to context via attributes
> - symbol spaces provide their own pluggable grammar to parse their
> declaration
>
> Mental model:
> sigils in perl already behaves like symbol space switch, for example:
> $foo = new value;
> can be treated as
> declared scalar foo = new value;
> More at
> https://github.com/happy-barney/perl-wish-list/tree/master/independent-symbol-spaces

Ok, I've your email above, I've looked at that web page, and I still
don't understand.

First, I'm going to make a very general point here.

From time to time you post on p5p about a proposal or whatever, and I
rarely have any idea what you mean. This may be because I don't
understand the subject area, or because you're not clear at explaining
things, or maybe a combination of the two. But for whatever reason, the
net affect is that such discussions don't go anywhere. I suspect that
other Porters are in the same boat as me. This is something you need to be
aware of in any future discussions.

Now back to the subject of namespaces. I understand the general concept of
multiple namespaces, but don't understand how you propose to implement and
use them in perl.

So far I get the vague idea that perl will be extended to allow
for sigil-ness names to be recognised by the parser in some fashion.
Then when someone wants to add a particular new syntactic feature to perl,
such as named regexes, they can tell the parser this in some fashion, so
that when the parser sees 'pattern foo ...', it knows to look up 'foo'
in a separate namespace associated with regexes. Is that right so far?

These namespaces would be declared by what - at the perl level? Or in the
core? Or both? Or what? Is that what the 'declare' statement is for?

And what does the parser do with a name? Currently when the parser sees
'$foo' or 'sub foo' or ''package foo', it is very specific about how 'foo'
is interpreted - so in addition to looking up the symbol in the correct
namespace, it it interpreted as a sub or package name or whatever and
parsing proceeds accordingly.

From your descriptions you seem to be taking about effectively parallel
namespaces within the existing namespace structure. So one particular
name would be interpreted as a 'package global' symbol and be looked up
the same way as package globals (such as $foo::bar would), but once the
name is resolved, it uses a further level of indirection, based on the
context (such as pattern names) to choose from an array of GPs in that GV?

And similar behaviour would apply for lexically-scoped names?

Note that both typeblobs and lexicals have a lot of run-time behaviour.
E.g. for typeglobs:

*x = \$y; # alias the SV slot in the GP
*x = *y; # alias the GP
$foo::{x} = $bar::{y}; # alias the GV

And lexicals get insanely complex. There can be multiple lexicals of the
same name within the same scope:

{
my $x = 1;
my $f1 = sub { $x }
my $x = 2;
my $f2 = sub { $x }
say $f1->(), $f2->(); # prints "12"
}

And the same name can bind to different SVs at various points during
compilation and execution, for example:

my $x;
sub {
sub f {
$x;
eval 'sub g { sub { BEGIN print $x } }';
}
}->();

What does it mean to look up a lexical regex name in a similar
environment:

pattern x = ....;
sub {
sub f {
x->match();
eval 'sub g { sub { BEGIN print x->match() } }';
}
}->();

do these parallel lexical namespaces do all the closure-related behaviour
that 'my' vars do? What about 'state' behaviour?

And so on.


--
In England there is a special word which means the last sunshine
of the summer. That word is "spring".
Re: Elevator pitch - independent symbol spaces [ In reply to ]
Hi Dave,

thanks for your response

On Wed, 18 Oct 2023 at 12:04, Dave Mitchell <davem@iabyn.com> wrote:

> On Thu, Oct 12, 2023 at 03:50:53PM +0200, Branislav Zahradník wrote:
> > On Thu, 12 Oct 2023 at 14:07, Dave Mitchell <davem@iabyn.com> wrote:
> > >
> > > I still don't really understand.
> > >
> > > Perl's existing namespaces are intimately tied to the lexer and parser,
> > > and their current state. For example, when the compiler sees '$foo', it
> > > searches through the chain of pads currently in scope for a '$foo'
> entry;
> > > if none are found, it searches for a 'foo' entry in the current stash,
> > > then looks for a scalar entry in that typeglob.
> > >
> >
> > > How would these new namespaces be used? What syntax and mechanisms
> would
> > > be in place to make use of these new namespaces?
> > >
> >
> > One question is missing: how to import/export these new symbols ?
> >
> > Very short answer:
> >
> > - typeglob will be changed to contain (dynamic) array for symbols in
> > particular symbol space
> > eg (demonstration of approach):
> > #define GvCV(gv) ((CV*)GvGP(gv)->gp_cv)
> > will be changed to:
> > #define GvCV(gv) ((CV*)GvGP(gv)->gp_symbols[SYMBOL_SPACE_CV])
> >
> > - pad - that I don't know yet, that's open question
> >
> > - lexer
> > - every usage of external symbol space is prefixed by distinct token
> > - new statement: declare
> > - new expression: declared
> > - new prototype similar to &;@ ... $<Symbol::Space::Identifier>
> > - symbol space behaviour will be attached to context via attributes
> > - symbol spaces provide their own pluggable grammar to parse their
> > declaration
> >
> > Mental model:
> > sigils in perl already behaves like symbol space switch, for example:
> > $foo = new value;
> > can be treated as
> > declared scalar foo = new value;
> > More at
> >
> https://github.com/happy-barney/perl-wish-list/tree/master/independent-symbol-spaces
>
> Ok, I've your email above, I've looked at that web page, and I still
> don't understand.
>
> First, I'm going to make a very general point here.
>
> From time to time you post on p5p about a proposal or whatever, and I
> rarely have any idea what you mean. This may be because I don't
> understand the subject area, or because you're not clear at explaining
> things, or maybe a combination of the two. But for whatever reason, the
> net affect is that such discussions don't go anywhere. I suspect that
> other Porters are in the same boat as me. This is something you need to be
> aware of in any future discussions.
>

Most likely it's me not being clear enough - I can describe end usage, I
can describe
how to achieve abstraction, but I cannot so far describe well that
abstraction
(I'd love to learn that).

So yes, I'm aware of that :-(


>
> Now back to the subject of namespaces. I understand the general concept of
> multiple namespaces, but don't understand how you propose to implement and
> use them in perl.
>
> So far I get the vague idea that perl will be extended to allow
> for sigil-ness names to be recognised by the parser in some fashion.
> Then when someone wants to add a particular new syntactic feature to perl,
> such as named regexes, they can tell the parser this in some fashion, so
> that when the parser sees 'pattern foo ...', it knows to look up 'foo'
> in a separate namespace associated with regexes. Is that right so far?
>

more or less yes, only difference is parser needs to see `declared pattern
foo`


>
> These namespaces would be declared by what - at the perl level? Or in the
> core? Or both? Or what? Is that what the 'declare' statement is for?
>

Both.

Yes, at perl level, that's for `declare` statement is for, with declaring
new symbol
in namespace `symbol_space`.


> And what does the parser do with a name? Currently when the parser sees
> '$foo' or 'sub foo' or ''package foo', it is very specific about how 'foo'
> is interpreted - so in addition to looking up the symbol in the correct
> namespace, it it interpreted as a sub or package name or whatever and
> parsing proceeds accordingly.
>

First, let me correct one term - instead of parser say "perl parser" - aka
perly.y and toke.c.

Perl parser will see them only in special contexts:
- declare statement
- declared expression
- and prototype extension

When it will see "declare <namespace> <symbol> as <content>"

abstract behaviour will be still same, let me use reverse examples, how
existing symbols
can be declared using this new statement.

$foo;
declare perl_scalar foo;

my $foo = 'bar';
my declare perl_scalar foo = 'bar';

sub foo ($self) { bar };
declare perl_sub foo as ($self) { bar };


Now anwser can continue in multiple branches, so first I'll address how
names should be handled.

Behaviour of guts (typeglob or pad) will be similar, except instead of
using restricted
set of namespaces there will be dynamic data structure to store them.

Re restricted set of namespaces:
- typeglob uses struct with pointer per existing namespace
- pad uses sigil in name to make name unique

Both should be adapted to be able to handle unlimited number of namespaces,
for example:
- typeglob - add dynamic array to GV
- pad - lookup key will be constructed eg as: chr (symbol table id) .
symbol name, with symbol table ids:
- 36 for scalars
- 64 for arrays
- 37 for hashes
- 256 for first non-internal symbol space

Names will be handled "perl way" independently on namespace they belong to:
$Some::Package::foo;
declared perl_scalar Some::Package::foo;

&Some::Package::foo;
declared perl_sub Some::Package::foo;

declared data_contract Some::Package::foo;


Second branch is how to handle scope.

Perl is great for providing multiple scopes - my, our, local, state, field,
...
(plus multiple implementations of global scope - keywords, misc built-ins -
attributes, UNIVERSAL, builtin package)

So providing these scopes for any kind of symbols will only make their
usage native.
Using example with possible data contracts.

# import some contracts
use My::Data::Contracts :contract(Foo, Bar);

# declare package-wide contract
declare contract Foo_Or_Bar as Foo | Bar;

sub foo {
# declare my contract Bar
my declare contract Bar as ! My::Data::Contracts::Bar;

# override Foo
local declare contract My::Data::Contracts::Foo as ...;
}


Third branch is syntax after 'as'.

That one is symbol space specific expression handled by pluggable grammar.
How result will be treated internally is open question.
Let's use imaginary placeholder YV* for now.


> From your descriptions you seem to be taking about effectively parallel
> namespaces within the existing namespace structure. So one particular
> name would be interpreted as a 'package global' symbol and be looked up
> the same way as package globals (such as $foo::bar would), but once the
> name is resolved, it uses a further level of indirection, based on the
> context (such as pattern names) to choose from an array of GPs in that GV?
>
> And similar behaviour would apply for lexically-scoped names?
>
> Note that both typeblobs and lexicals have a lot of run-time behaviour.
> E.g. for typeglobs:
>
> *x = \$y; # alias the SV slot in the GP
> *x = *y; # alias the GP
> $foo::{x} = $bar::{y}; # alias the GV
>

As far as naming resolution is up to perl this should work for any kind of
symbol space:

eg:
*x = \ declared contract Foo;



>
> And lexicals get insanely complex. There can be multiple lexicals of the
> same name within the same scope:
>
> {
> my $x = 1;
> my $f1 = sub { $x }
> my $x = 2;
> my $f2 = sub { $x }
> say $f1->(), $f2->(); # prints "12"
> }
>
>
same, imagine your code written as
{
my declare perl_scalar x = 1;
my declare perl_scalar f1 = sub { declared perl_scalar x };
my declare perl_scalar x = 2;
my declare perl_scalar f2 = sub { declared perl_scalar x };

say declared scalar f1->(), declared scalar f2->();
}

You can just imagine "declare <symbol space>" and "declared <symbol space>"
as sigils
(in some way)

And the same name can bind to different SVs at various points during
> compilation and execution, for example:
>
> my $x;
> sub {
> sub f {
> $x;
> eval 'sub g { sub { BEGIN print $x } }';
> }
> }->();
>
> What does it mean to look up a lexical regex name in a similar
> environment:
>
> pattern x = ....;
> sub {
> sub f {
> x->match();
> eval 'sub g { sub { BEGIN print x->match() } }';
> }
> }->();
>
>
Two answers here:
scoping - that one will by still same

syntax
independent symbols are not visible to perl grammar unless
- they are part of declare/declared
- used in symbol space attribute
- used in part of grammar which understands them (in this case regexp
parser)

So your code will be working only as:
declare pattern x as ...;
sub {
sub f {
m/(?&x)/;
# or
declared pattern x ->match ();
... same for eval part
}
}


> do these parallel lexical namespaces do all the closure-related behaviour
> that 'my' vars do? What about 'state' behaviour?
>
> And so on.
>
>
This is really shame on me, I tried to explicitly express this :-(

Yes, everything you can do with existing symbols you should be able to do
with independent symbols.
Independent symbols must always be prefixed with introductory syntax
(declare / declared / symbol space attribute),
otherwise it may be treated as sub / glob / format ... whatever Perl finds
suitable.


>
> --
> In England there is a special word which means the last sunshine
> of the summer. That word is "spring".
>
Re: Elevator pitch - independent symbol spaces [ In reply to ]
Hi there,

On Wed, 18 Oct 2023, Branislav Zahradn?k wrote:

> ...
declare perl_scalar foo;
> ...
my declare perl_scalar foo = 'bar';
> ...
declare perl_sub foo as ($self) { bar };
> ...
> ... everything you can do with existing symbols you should be able
> to do with independent symbols. ...

Have you made any estimate of the effort, in for example man-years of
coder time, that it's likely to take to implement your ideas?

--

73,
Ged.
Re: Elevator pitch - independent symbol spaces [ In reply to ]
>
> Have you made any estimate of the effort, in for example man-years of
> coder time, that it's likely to take to implement your ideas?
>

provided I have few ideas every day I'd say eternity :-)

limiting to scope of $subj for Oshun and attributes, not so much.
what I need is to do is:
- how to update typeglob and pad to store these values
- how to store symbol value
- new C API
- new grammar
- import / export

Re typeglob and pad
- both will need to work also in multi-key lookup (symbol space, symbol
name) - rest is already implemented by perl
suggested extension:
- dynamic array in typeglob (described in documents on github)
- artificial sigil in pad (described in this thread)

- how to store symbol value
- to be discussed, but:
- it needs to behave like SV
- it needs to store symbol space identification
- it needs to store value provided by executing OP returned by
pluggable grammar

- new C API
- to be discussed

- new grammar
- adding one statement and one expression, both under feature, both
non-conflicting

- import / export may be challenging if it will be required to stick with
current behaviour (import, @EXPORT, and co)
- extending "use" will be much easier with WIP attribute workflow, based
on abstractions provided by independent symbol spaces

Brano


>
> --
>
> 73,
> Ged.
Re: Elevator pitch - independent symbol spaces [ In reply to ]
Hi there,

On Wed, 18 Oct 2023, Branislav Zahradník wrote:
> On Wed, 18 Oct 2023, G.W. Haywood wrote:
>
>> Have you made any estimate of the effort, in for example man-years of
>> coder time, that it's likely to take to implement your ideas?
>
> ... not so much.
> what I need is to do is:
> [snip]

Please forgive me for pressing the question.

How much effort?

--

73,
Ged.
Re: Elevator pitch - independent symbol spaces [ In reply to ]
On Wed, 18 Oct 2023 at 16:32, G.W. Haywood via perl5-porters <
perl5-porters@perl.org> wrote:

> Hi there,
>
> On Wed, 18 Oct 2023, Branislav Zahradník wrote:
> > On Wed, 18 Oct 2023, G.W. Haywood wrote:
> >
> >> Have you made any estimate of the effort, in for example man-years of
> >> coder time, that it's likely to take to implement your ideas?
> >
> > ... not so much.
> > what I need is to do is:
> > [snip]
>
> Please forgive me for pressing the question.
>
> How much effort?
>

Ask me once "to be discuss" topics are discussed.

I may have some overview but I do not have deep insight in every affected
area.

That's why I started this thread



>
> --
>
> 73,
> Ged.