Re: Found Good docs - Revisiting Pike

2026-01-10 Thread Duke Normandin
@ Leif Stensson

I had not received any posts from the Pike mailing list, so I visited the Pike
mailing list archives and found your reply.

I'm very weak with functional programming and a total newbie to OOP, so I will
have to study more to understand your reply. For now, I at least know that
there is a reason for syntax.  Thank you!
--
Duke



Found Good docs - Revisiting Pike

2026-01-08 Thread Leif Stensson, Lysator @ Pike importm�te f�r mailinglistan
Hi,

  > I don't understand the `[] and `-> syntax. I need some simple
  > examples of usage. Also a ->ident aka a["ident"] escapes me. What
  > is meant by "Ident" i.e. "Identifier"?

The backtick versions, `[] and `->, are the names of the operations as
functions. For example, you could do:

  `[](obj, ind)

and it would be equivalent obj[ind]. This may seem kind of useless
when used directly like this, but if can be useful when you need to
pass the function as an argument to another function, or if you want
to overload the indexing operations in a class; then you need some way
of referring to the indexing functions themselves without immediately
using them the way you would with obj[ind].




/ Leif



Re: Found Good docs - Revisiting Pike

2026-01-08 Thread Duke Normandin
On Thu, 8 Jan 2026 15:44:52 -0700
Duke Normandin  wrote:

> I'm currently studying the pike manual/chapter_5.html#5.5 Indexing
> 
> A sample quote:
> 
> Function SyntaxIdent   Returns
> 
> Index   a [ b ]`[]   Returns the index b from a. 
> 
> Safe Index  a [? b ]   none  Returns the index b from a, returning 0
> instead of an error of a is 0
> 
> Lookupa ->ident  `->  Looks up the identifier. Same as
> a["ident"].
> 
> I don't understand the `[] and `-> syntax. I need some simple examples of
> usage. Also a ->ident aka a["ident"] escapes me. What is meant by "Ident" i.e.
> "Identifier"?

Found a clue!!

string str;
str = "pike";
str[2]; => 107
`[](str,2)  => 107

Which of these two constructs is preferable?
Is there a reason for having two ways of indexing?
-- 
Duke



Found Good docs - Revisiting Pike

2026-01-08 Thread Duke Normandin
I'm currently studying the pike manual/chapter_5.html#5.5 Indexing

A sample quote:

Function SyntaxIdent Returns

Index   a [ b ]`[]   Returns the index b from a. 

Safe Index  a [? b ]   none  Returns the index b from a, returning 0 instead
 of an error of a is 0

Lookup  a ->ident  `->  Looks up the identifier. Same as
a["ident"].

I don't understand the `[] and `-> syntax. I need some simple examples of usage.
Also a ->ident aka a["ident"] escapes me. What is meant by "Ident" i.e.
"Identifier"?

TIA !
-- 
Duke