home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.forth      Forth programmers eat a lot of Bratwurst      117,927 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 116,931 of 117,927   
   Ruvim to Anthony Howe   
   Re: Toad using many vocabularies   
   01 Nov 24 21:35:39   
   
   From: ruvim.pinka@gmail.com   
      
   On 2024-11-01 19:08, Anthony Howe wrote:   
   > On 2024-11-01 10:28, Ruvim wrote:   
   >> Such a syntax is used in SP-Forth/4 since 2001, in the form   
   >> :: or ::::   
   >>   
   >> Where  is a word that returns wid, or a word that is created with   
   >> `vocabulary`.   
   >>   
   >> This syntax in SP-Forth probably came after C++ "::" operator,   
   >> introduced in 1998.  The same operator was in C# from its initial   
   >> release in 2000.   
   >  >   
   >> The dot "." operator for accessing nested packages in Java was   
   >> introduced in 1995.   
   >>   
   >> In Forth, a dot is often used as part of plain names, so it was less   
   >> suitable as a namespace separator.   
   >   
   > Yep.  Bad idea to use dot.   
      
   Do you mean to use dot in names or to use dot as a namespace separator   
   in Forth?   
      
      
   > Never liked `::`, found it visually distasteful.   
      
   Agreed. But there no very good choices, as you mentioned below ))   
      
   >   
   > Dare I suggest C's `->` which trumps others by decades.   
      
      
   BTW, as far as I understand, the `->` operator in C is not about   
   namespaces, but about dereferencing a pointer and accessing a structure   
   member.   
      
   So,  `ptr->field` is a shorthand for `(*ptr).field`   
      
   That is, `ptr` is not a namespace. The namespace (in which the name   
   `field` is resolved) is inferred from the *data type* of `ptr`.   
      
      
   > Or simply create a new one like `:>` or  `~` (oh I'll be stoned for this   
   > one). I would prefer a single character, but there are so few good choices.   
   >   
      
      
   At the moment, I like the XML namespaces syntax the best.   
      
   The idea is that we associate a long namespace identifier with a short   
   prefix, which is only valid within its lexical scope.   
      
   The syntax is:  :   
      
   Since a prefix is ​​valid in a limited scope, it can be short without   
   risk of conflicts/clashes. Typically, only a few sibling prefixes are   
   used in a module.   
      
   So, a name is qualified by its namespace using only one short prefix,   
   regardless how deep this namespace is nested.   
      
   Of course, there can be some predefined prefixes (which can still be   
   shadowed).   
      
      
   For example, I want to use a module:   
      
      
   There can be a special mapping `github` to treat modules from GitHub.   
      
   At an API level it could be like this:   
      
      "github:ForthHub/fep-recognizer/implementation/lib/string-match.fth"   
      "str" module:push-prefix   
      
      "foobar" "foo" str:starts-with .  \ should print -1   
      
      module:drop-prefix   
      
      
   Under the hood, the system should download the package   
   "github:ForthHub/fep-recognizer" (if it hasn't already cached), then the   
   module "implementation/lib/string-match.fth" from this package should be   
   instantiated in memory it its own word list (if it hasn't already), then   
   the prefix "str" is associated with the word list of this module.   
      
   The lexeme "str:starts-with" is processed by the recognizer of prefixes,   
   which extracts the prefix "str", obtains the corresponding word list,   
   finds "starts-with" in that word list, and returns the name token for   
   the word and the name token translator, as `( nt tt-nt )`. The Forth   
   text interpreter executes `tt-nt` (which is an xt) to perform the   
   compilation semantics or interpretation semantics for the word according   
   to the current state.   
      
      
   --   
   Ruvim   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca