Programmer Checkin
Post Reply
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
14-04-2017, 04:34 AM
RE: Programmer Checkin
(14-04-2017 12:47 AM)f stop Wrote:  I have no idea what you mean by "lexical scoping."

It's when the nice nurse takes a flexible tube...

We'll love you just the way you are
If you're perfect -- Alanis Morissette
(06-02-2014 03:47 PM)Momsurroundedbyboys Wrote:  And I'm giving myself a conclusion again from all the facepalming.
Find all posts by this user
Like Post Quote this message in a reply
[+] 3 users Like morondog's post
14-04-2017, 06:17 AM (This post was last modified: 14-04-2017 06:32 AM by GirlyMan.)
RE: Programmer Checkin
(14-04-2017 12:47 AM)f stop Wrote:  
(12-04-2017 12:59 AM)GirlyMan Wrote:  Why did you highlight scoping rules? C uses lexical scoping.
Maybe I'm too old but to me the word scoping implies control over which parts of the code can be seen, and thus changed, by the various procedures in the code. One of the shortcomings of C (IMHO) is that it is impossible to nest procedures within procedures, a feature that I have found useful in other languages.

I have no idea what you mean by "lexical scoping."

Same concept but with variable name bindings. It refers to where in the code can the variable be seen and referred to by that name. "Lexical" just means the portion of source code in which a binding of a name with an entity can be seen. Sometimes called static scoping because the blocks of code which can see the variable are predetermined at compile time. It's been around since ALGOL 60. You must be really old.

I use function nesting, especially inline and anonymous function lambda expressions in C#, a lot during development. Mainly for convenience. I hate jumping around to different parts of the code just to define a function when I need it right here right now. I'll move it broader scope later if I need it somewhere else. If I don't, just leave it be.

C doesn't support function nesting but it does support functions pointers as parameters to other functions which can be used to accomplish the same things as function nesting. And I know it's probably been a while for you Grampa but all the cool kids are using these things called Wikpedia and Google now. It's like having a university library at your fingertips. Shocking Tongue

There is only one really serious philosophical question, and that is suicide. -Camus
Find all posts by this user
Like Post Quote this message in a reply
[+] 1 user Likes GirlyMan's post
14-04-2017, 08:35 AM
RE: Programmer Checkin
(14-04-2017 06:17 AM)GirlyMan Wrote:  
(14-04-2017 12:47 AM)f stop Wrote:  Maybe I'm too old but to me the word scoping implies control over which parts of the code can be seen, and thus changed, by the various procedures in the code. One of the shortcomings of C (IMHO) is that it is impossible to nest procedures within procedures, a feature that I have found useful in other languages.

I have no idea what you mean by "lexical scoping."

Same concept but with variable name bindings. It refers to where in the code can the variable be seen and referred to by that name. "Lexical" just means the portion of source code in which a binding of a name with an entity can be seen. Sometimes called static scoping because the blocks of code which can see the variable are predetermined at compile time. It's been around since ALGOL 60. You must be really old.

I use function nesting, especially inline and anonymous function lambda expressions in C#, a lot during development. Mainly for convenience. I hate jumping around to different parts of the code just to define a function when I need it right here right now. I'll move it broader scope later if I need it somewhere else. If I don't, just leave it be.

C doesn't support function nesting but it does support functions pointers as parameters to other functions which can be used to accomplish the same things as function nesting. And I know it's probably been a while for you Grampa but all the cool kids are using these things called Wikpedia and Google now. It's like having a university library at your fingertips. Shocking Tongue

Because it doesn't have function nesting, C is terrible at implementing closures. Closures are at their best when they can easily borrow scope from the parent function. Ultimately it can be done, but you have to explicitly share the scope. Thus where closures would simplify things, attempting to use one in C actually complicates them. One is better off just ignoring closures and finding a workaround. To be fair, a lifelong C programmer might not even realize they need closures, because they have always worked around them. Each language has its purpose and so can't be expected to be good at everything.

We have to remember that what we observe is not nature herself, but nature exposed to our method of questioning ~ Werner Heisenberg
Find all posts by this user
Like Post Quote this message in a reply
[+] 1 user Likes tomilay's post
14-04-2017, 08:51 AM
RE: Programmer Checkin
(13-04-2017 11:53 AM)Mathilda Wrote:  I lost the use of my hands within the space of a week, couldn't even hold a pen and sign my name or use both a knife and fork together.

That's awful and I'm very sorry to hear it. I'll be thinking of you and hoping for the best.

(13-04-2017 11:53 AM)Mathilda Wrote:  People always say that there must be some kiind of speech recongnition

AHHHHH HA HA ha ha... Laugh out load ha... no. Weeping God, that'd be worse than writing LabVIEW with a touch pad (as a graphical language, using a touch pad is one step down even from trying to install Python modules on an offline machine).
Find all posts by this user
Like Post Quote this message in a reply
[+] 2 users Like kmc's post
14-04-2017, 09:01 AM
RE: Programmer Checkin
(14-04-2017 08:51 AM)kmc Wrote:  
(13-04-2017 11:53 AM)Mathilda Wrote:  I lost the use of my hands within the space of a week, couldn't even hold a pen and sign my name or use both a knife and fork together.

That's awful and I'm very sorry to hear it. I'll be thinking of you and hoping for the best.

(13-04-2017 11:53 AM)Mathilda Wrote:  People always say that there must be some kiind of speech recongnition

AHHHHH HA HA ha ha... Laugh out load ha... no. Weeping God, that'd be worse than writing LabVIEW with a touch pad (as a graphical language, using a touch pad is one step down even from trying to install Python modules on an offline machine).

LabVIEW with a touchpad?! Ohmy
Find all posts by this user
Like Post Quote this message in a reply
[+] 1 user Likes Fireball's post
14-04-2017, 12:04 PM
RE: Programmer Checkin
(13-04-2017 06:53 PM)GirlyMan Wrote:  
(13-04-2017 06:35 PM)tomilay Wrote:  You should be able to debug C on emacs using gdb if you are on a *nix platform. If you are on Windows...oh well..yeah

What I see all the cool kids doing today is running VMs of whatever OS they want. Hell I've seem 'em use VMs as an organizing tool, each app gets a machine of its own. Now they got as many computers as they want. Crazy kids.

Yabut, not really - only virtually. Dodgy

I have a 8-processor, 32Gb server running WinServer 2008 with VMs for XP, Win7, Win8, WinServer 2003, Linux, and I need to add a Win10 VM.
This is all for compatibility testing for our products. And it was fun to build. Thumbsup

Skepticism is not a position; it is an approach to claims.
Science is not a subject, but a method.
[Image: flagstiny%206.gif]
Visit this user's website Find all posts by this user
Like Post Quote this message in a reply
[+] 1 user Likes Chas's post
14-04-2017, 12:07 PM
RE: Programmer Checkin
(14-04-2017 08:35 AM)tomilay Wrote:  Each language has its purpose and so can't be expected to be good at everything.

No, but they tried with Ada. It was too heavy to fly.

Skepticism is not a position; it is an approach to claims.
Science is not a subject, but a method.
[Image: flagstiny%206.gif]
Visit this user's website Find all posts by this user
Like Post Quote this message in a reply
[+] 3 users Like Chas's post
14-04-2017, 12:15 PM (This post was last modified: 14-04-2017 12:18 PM by GirlyMan.)
RE: Programmer Checkin
(14-04-2017 08:35 AM)tomilay Wrote:  Because it doesn't have function nesting, C is terrible at implementing closures. Closures are at their best when they can easily borrow scope from the parent function. Ultimately it can be done, but you have to explicitly share the scope. Thus where closures would simplify things, attempting to use one in C actually complicates them. One is better off just ignoring closures and finding a workaround.

It does have block closures though. When I use a nested function I try to be careful to consider whether I will want to reuse it later first. Relying on parent function state complicates refactoring later. I usually only use them when it's support code I know is specific to the function I'm in and I need to invoke it multiple times. Doesn't make sense to expose its name, only muddies the waters. Kind of as a logical extension of private methods. Anonymous methods are the truly double super-secret private methods.

There is only one really serious philosophical question, and that is suicide. -Camus
Find all posts by this user
Like Post Quote this message in a reply
14-04-2017, 01:03 PM
RE: Programmer Checkin
(14-04-2017 12:15 PM)GirlyMan Wrote:  
(14-04-2017 08:35 AM)tomilay Wrote:  Because it doesn't have function nesting, C is terrible at implementing closures. Closures are at their best when they can easily borrow scope from the parent function. Ultimately it can be done, but you have to explicitly share the scope. Thus where closures would simplify things, attempting to use one in C actually complicates them. One is better off just ignoring closures and finding a workaround.

It does have block closures though. When I use a nested function I try to be careful to consider whether I will want to reuse it later first. Relying on parent function state complicates refactoring later. I usually only use them when it's support code I know is specific to the function I'm in and I need to invoke it multiple times. Doesn't make sense to expose its name, only muddies the waters. Kind of as a logical extension of private methods. Anonymous methods are the truly double super-secret private methods.

Got ya. Makes sense.

Where I have seen closures really handy is in javascript frameworks like jQuery. The underlying idea being to actually export parent function state.

Because objects in javascript are glorified functions, you end up with something like the ability to have different instances of an object with the closure mimicking a class and providing a context common to all instances. A lot of javascript design patterns literally depend on closures.

We have to remember that what we observe is not nature herself, but nature exposed to our method of questioning ~ Werner Heisenberg
Find all posts by this user
Like Post Quote this message in a reply
[+] 1 user Likes tomilay's post
14-04-2017, 01:09 PM
RE: Programmer Checkin
(14-04-2017 01:03 PM)tomilay Wrote:  
(14-04-2017 12:15 PM)GirlyMan Wrote:  It does have block closures though. When I use a nested function I try to be careful to consider whether I will want to reuse it later first. Relying on parent function state complicates refactoring later. I usually only use them when it's support code I know is specific to the function I'm in and I need to invoke it multiple times. Doesn't make sense to expose its name, only muddies the waters. Kind of as a logical extension of private methods. Anonymous methods are the truly double super-secret private methods.

Got ya. Makes sense.

Where I have seen closures really handy is in javascript frameworks like jQuery. The underlying idea being to actually export parent function state.

Because objects in javascript are glorified functions, you end up with something like the ability to have different instances of an object with the closure mimicking a class and providing a context common to all instances. A lot of javascript design patterns literally depend on closures.

Ah, I see. Shared state on demand. That's pretty cool.

There is only one really serious philosophical question, and that is suicide. -Camus
Find all posts by this user
Like Post Quote this message in a reply
[+] 1 user Likes GirlyMan's post
Post Reply
Forum Jump: