Libre RISC-V Mailing list Archives (accessible via public-inbox)
 help / color / Atom feed
From: bugzilla-daemon@libre-soc.org
To: libre-riscv-dev@lists.libre-riscv.org
Subject: [libre-riscv-dev] [Bug 353] formal proof of soc.regfile classes RegFile and RegFileArray needed
Date: Wed, 27 May 2020 18:40:38 +0000
Message-ID: <bug-353-13-yY0tQCRLgp@https.bugs.libre-soc.org/> (raw)
In-Reply-To: <bug-353-13@https.bugs.libre-soc.org/>

https://bugs.libre-soc.org/show_bug.cgi?id=353

--- Comment #7 from Cole Poirier <colepoirier@gmail.com> ---
(In reply to Luke Kenneth Casson Leighton from comment #6)
> (In reply to Cole Poirier from comment #5)
> 
> > Are class attributes (self.x) declared within __init__ public and those
> > declared within elaborate() private? 
> 
> in python the concept of public and private in classes does not exist, like
> it does in c++
> 
> class instance atttributes are therefore *always* public.  there does exist
> however a convention that if something starts with underscores it is *by
> convention* considered "not for public use".
> 
> what you are getting confused about is "scope".
> 
> within a function, any local variables are entirely local.  however note
> that stuff declared in a module is *also* accessible within the function.
> 
> therefore, only variables created *inside* the function are private scope to
> that function.

Thank you for clarifying this for me. My first language three years ago was
python (primarily pandas and numpy for data analysis), so I'm reasonably
comfortable with python scopes, the mistake I made was not thinking I had to
call elaborate first, which is about as silly. I also appreciate the review of
python vs c/c++, but I'm only proficient in python and rust, (and javascript if
I absolutely must**), so my OOP knowledge only comes from python, I don't know
how to write the other stuff like public/private classes, I can only sort of
read it because I've had to learn to understand when reading c/c++/java/go
code.

**I prefer doing UI in elm, which is a functional language that's designed
specifically for UI design that's transpiled to js. I bring this up because I
think you might find interesting to check out in a free moment because of your
work on pyjamas

> > I though all python class attributes
> > were public, and in order to get 'private' variables in a class you have to
> > do as you did in virtual_port.py by simply declaring it a variable and not
> > an attribute of the class object. I ask because I'm having an issue where
> > I'm trying to access self.reg of class Register(), which is declared inside
> > elaborate(),
> 
> no it is not declared (this is not c), it is created, and it is created only
> when the function elaborate is called.
> 
> how can you expect Register.reg to be created when Register.elaborate has
> not been called?
> 
> > and I get an error, but accessing any of the self.xyz
> > attributes like self.width declared in __init__ works fine.
> 
> this is correct behaviour.  python is not a static language.
> 
> commit it let's have a look.

With you... now. Pushed my commit.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
libre-riscv-dev mailing list
libre-riscv-dev@lists.libre-riscv.org
http://lists.libre-riscv.org/mailman/listinfo/libre-riscv-dev

  parent reply index

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-26  0:13 [libre-riscv-dev] [Bug 353] New: " bugzilla-daemon
2020-05-26  0:13 ` [libre-riscv-dev] [Bug 353] " bugzilla-daemon
2020-05-26 23:20 ` bugzilla-daemon
2020-05-27  4:12 ` bugzilla-daemon
2020-05-27 11:14 ` bugzilla-daemon
2020-05-27 16:45 ` bugzilla-daemon
2020-05-27 17:26 ` bugzilla-daemon
2020-05-27 17:42 ` bugzilla-daemon
2020-05-27 18:08 ` bugzilla-daemon
2020-05-27 18:40 ` bugzilla-daemon [this message]
2020-05-27 18:48 ` bugzilla-daemon
2020-05-27 18:56 ` bugzilla-daemon
2020-05-27 19:25 ` bugzilla-daemon
2020-05-27 19:43 ` bugzilla-daemon
2020-05-28  1:18 ` bugzilla-daemon
2020-05-28  1:33 ` bugzilla-daemon
2020-05-28  1:50 ` bugzilla-daemon
2020-05-28  2:59 ` bugzilla-daemon
2020-05-28 10:18 ` bugzilla-daemon
2020-05-28 14:18 ` bugzilla-daemon
2020-05-28 16:41 ` bugzilla-daemon
2020-05-28 19:50 ` bugzilla-daemon
2020-05-28 20:00 ` bugzilla-daemon
2020-05-28 20:27 ` bugzilla-daemon
2020-05-28 23:18 ` bugzilla-daemon
2020-05-28 23:41 ` bugzilla-daemon
2020-05-28 23:57 ` bugzilla-daemon
2020-05-30 21:41 ` bugzilla-daemon
2020-05-30 22:03 ` bugzilla-daemon
2020-05-30 22:13 ` bugzilla-daemon
2020-05-30 22:38 ` bugzilla-daemon
2020-05-31 14:12 ` bugzilla-daemon
2020-05-31 18:20 ` bugzilla-daemon
2020-06-01 17:06 ` bugzilla-daemon
2020-06-01 17:51 ` bugzilla-daemon
2020-06-01 17:52 ` bugzilla-daemon
2020-06-01 17:53 ` bugzilla-daemon
2020-06-01 17:55 ` bugzilla-daemon
2020-06-01 18:06 ` bugzilla-daemon
2020-06-01 18:07 ` bugzilla-daemon
2020-06-01 18:35 ` bugzilla-daemon
2020-06-02 12:27 ` bugzilla-daemon

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=bug-353-13-yY0tQCRLgp@https.bugs.libre-soc.org/ \
    --to=bugzilla-daemon@libre-soc.org \
    --cc=libre-riscv-dev@lists.libre-riscv.org \
    /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

Libre RISC-V Mailing list Archives (accessible via public-inbox)

Archives are clonable: git clone --mirror https://inbox.libre-soc.org/libre-riscv-dev

Example config snippet for mirrors


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git