Wikipedia:Reference desk/Archives/Computing/2018 June 9
Computing desk | ||
---|---|---|
< June 8 | << May | June | Jul >> | June 10 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
June 9
editSemantic hierarchy principle?
editIs there a name for the following principle in programming language design?
- Each node in the abstract syntax tree should correspond to a substring of the program text, with each node's substring being disjoint from its siblings' and contained by its parent's.
- The node's semantic meaning should be determined principally (if not entirely) by its substring and lookup of any names therein.
An example discouraged by this principle is the compound comparison in Inform 6: x > 3 or y
means , whereas x == 3 or y
means . This makes it difficult to assign any meaningful semantics to the 3 or y
AST node: it is treated as an instruction to generate code to repeatedly apply the nearby operator. (One can salvage the situation by deeming it to represent a lazy sequence over which comparisons are mapped, but having such an entity appear in place of an expression is strange since it cannot appear in any other context where an expression is allowed.) In Haskell, by contrast, one could create a saturating monad from (x >)
or (x ==)
and apply it to each element of a list [3,y]
but that list has a fixed set of semantics independent of the tests performed on its members.
The second point is related to the idea of using context-free grammars for programming languages, but differs in two ways:
- The concern is with the (human-centric) semantics of a construct, not its initial parsing.
- A CFG says that what may mean some fixed thing (what may be reduced to a given non-terminal) does not depend on context, whereas #2 says that what some fixed thing means (to what a substring may be reduced) does not depend on context.
I think I've seen something written about it, maybe even on Wikipedia, but my searching has been unsuccessful. Thanks for any pointers. --Tardis (talk) 04:03, 9 June 2018 (UTC)
- I did eventually find it: the principle of compositionality (which also links to a programming-specific section). --Tardis (talk) 23:04, 17 July 2021 (UTC)
Is a computer whose clock drifts by about 2 seconds a day usual?
editI noticed my computer's time gets about 2 seconds behind per 24 hours. I'm running Windows 7 but I assume that has more to do with the hardware. Is that usual in your experience? Could it have anything to do with the stability of the frequency of the electric grid? Thanks. Basemetal 17:14, 9 June 2018 (UTC)
- This is not unusual but modern computers can synchronize their clocks via internet. It your case the synchronization does not work. Ruslik_Zero 17:45, 9 June 2018 (UTC)
- It does work. It does automatically synchronize every 7 days with time.windows.com. What I meant was, it drifts between synchronizations. That was what my question was about. When I see it's drifted like that I do manually have it synchronize with the Internet time server. But is there a way to set things up so that it automatically synchronizes with the time server not every 7 days but once a day? Basemetal 18:06, 9 June 2018 (UTC)
- It doesn't have to do with the timed frequency of the electric grid, but probably with the inherent frequency of a quartz crystal. In the 1960s and 1970s, in North America, time was kept using electric clocks with synchronous motors that spun at the frequency of the 60-hertz line current. This meant that it was important for the electric utility to provide line current that alternated 60 times a second, not 59 or 61 times a second, and so the utility would slow down or speed up their alternating current as needed to stay on track, presumably compared to an atomic clock maintained by the utility or to the WWV master clock. More recently quartz crystals, which have an inherent frequency, are the usual means of keeping time, in digital clocks, and in computational devices. Cell phones synchronize their clocks to the cell carrier. This enables them to reset the time automatically on crossing a time zone boundary (or on being turned back on when the airplane lands). As Ruslik notes, it appears that you, User:Basemetal, have two annoying problems. First, the quartz crystal in your computer is slow by about 2/86,400. Second, your computer is only setting itself to the Internet once a week. Robert McClenon (talk) 18:15, 9 June 2018 (UTC)
- While you are correct about the basic operation of the different clocks, strict control of the electric network frequency is inherent in the way the network operates. Classical generators naturally produce AC at a frequency directly proportional to their speed of rotation. This is used to coordinate supply and demand across the grid. All generators are operating in sync. If demand exceeds supply, the frequency on the whole grid drops slightly. On the one hand, this is buffered by the rotating masses of the generators (i.e. some of the kinetic energy of the generators is temporarily tapped to make up for the lack of production), on the other hand this signal is used in a control loop to increase (or decrease, in the opposite case) production. --Stephan Schulz (talk) 18:47, 9 June 2018 (UTC)
- Thank you both for these interesting facts. Basemetal 20:11, 9 June 2018 (UTC)
- While you are correct about the basic operation of the different clocks, strict control of the electric network frequency is inherent in the way the network operates. Classical generators naturally produce AC at a frequency directly proportional to their speed of rotation. This is used to coordinate supply and demand across the grid. All generators are operating in sync. If demand exceeds supply, the frequency on the whole grid drops slightly. On the one hand, this is buffered by the rotating masses of the generators (i.e. some of the kinetic energy of the generators is temporarily tapped to make up for the lack of production), on the other hand this signal is used in a control loop to increase (or decrease, in the opposite case) production. --Stephan Schulz (talk) 18:47, 9 June 2018 (UTC)
- It doesn't have to do with the timed frequency of the electric grid, but probably with the inherent frequency of a quartz crystal. In the 1960s and 1970s, in North America, time was kept using electric clocks with synchronous motors that spun at the frequency of the 60-hertz line current. This meant that it was important for the electric utility to provide line current that alternated 60 times a second, not 59 or 61 times a second, and so the utility would slow down or speed up their alternating current as needed to stay on track, presumably compared to an atomic clock maintained by the utility or to the WWV master clock. More recently quartz crystals, which have an inherent frequency, are the usual means of keeping time, in digital clocks, and in computational devices. Cell phones synchronize their clocks to the cell carrier. This enables them to reset the time automatically on crossing a time zone boundary (or on being turned back on when the airplane lands). As Ruslik notes, it appears that you, User:Basemetal, have two annoying problems. First, the quartz crystal in your computer is slow by about 2/86,400. Second, your computer is only setting itself to the Internet once a week. Robert McClenon (talk) 18:15, 9 June 2018 (UTC)
- It does work. It does automatically synchronize every 7 days with time.windows.com. What I meant was, it drifts between synchronizations. That was what my question was about. When I see it's drifted like that I do manually have it synchronize with the Internet time server. But is there a way to set things up so that it automatically synchronizes with the time server not every 7 days but once a day? Basemetal 18:06, 9 June 2018 (UTC)
- @Basemetal: You can configure the system to synchronize the clock more often. I have asked Google How to change the clock synchronization interval in Windows 7 and got several useful answers on the first page of hits. I'm not going to write them here, because it involves editing registry settings and any error in transcribing might render the answer useless or even harmful. Please read what Google returns, and don't hesitate to ask further questions if anything seems obscure. HTH. --CiaPan (talk) 18:29, 9 June 2018 (UTC)
- Thank you CiaPan. It worked and it wasn't that difficult after all. I followed the instructions at the first Google result namely wikihow which I found the most clear and convenient. Basemetal 20:11, 9 June 2018 (UTC)
- I don't know anything about Windows, but NTP-based solutions have been able to correct for a systematic clock drift since approximately the late stone age. --Stephan Schulz (talk) 18:33, 9 June 2018 (UTC)
- Robert says "Cell phones synchronize their clocks to the cell carrier". What is "the cell carrier"? Is it the radio wave which connects the cellphone to the base station? If it is, how does it control the cellphone clock? 2A02:C7F:BE08:2100:D8E2:5130:CE1:BD4B (talk) 16:44, 10 June 2018 (UTC)
- Carrier is another term for Mobile phone operator, the company that provides service for a phone. Cell phones regularly send and receive small signals to nearby cell phone towers, to assign the phone to the most readily available tower. SMS messages originally used that signal (which is why it was restricted to something like 140 characters) instead of the usual message. Ian.thomson (talk) 17:03, 10 June 2018 (UTC)
- Robert says "Cell phones synchronize their clocks to the cell carrier". What is "the cell carrier"? Is it the radio wave which connects the cellphone to the base station? If it is, how does it control the cellphone clock? 2A02:C7F:BE08:2100:D8E2:5130:CE1:BD4B (talk) 16:44, 10 June 2018 (UTC)
4,6: 14 or 25 MHz,
8: was used for CPU in some XT/AT-PCs.
- A personal computer usually is not late. Since NTP, the clock is synchronized. Former PCs used an dedicated clock generator which is now part of the chipset or integrated into CPU, least if the PC is a SoC. In the generation of dedicated clock generators, another 32.768 kHz quartz (crystal oscillator) was the time base of the CMOS real-time clock. This frequency can be digitally divided exact to one second. Today, You may find this small cylinder shaped plain metal quartz device (see picture, 1st item on the left). 14.x MHz is the base of the PC clock generator, 25. MHz ist the ethernet controller time base. Increasing the capacity by a soldering dot and restoring the ceramic capacitors capacity next to the 32.768 kHz quartz by heating up exceeding 120°C, also achieved by soldering during computer is turned off can slow down the PCs time base. --Hans Haase (有问题吗) 15:39, 11 June 2018 (UTC)
Steady clock drift from the xtal timebase being slightly inaccurate is easily compensated in software (hwclock command in linux, and there must be something like that in windows). You shouldn't have to use a soldering iron. There will still be some inherent variability but it should be much better than 2 sec/day. The other cause of drift is the OS sometimes not noticing timer ticks. I don't know why that happens but is a thing. 173.228.123.166 (talk) 18:36, 11 June 2018 (UTC)
- Hans Haase mentions the clock part of CMOS, but I don't see mention of the battery. When the CMOS battery begins to fail, the CMOS clock will commonly run slower. When the battery completely fails, the clock will reset to Jan 1, 1970 (or an equivalent Epoch) when the computer is shut down and restarted. I feel that most people don't use old computers. I have had to replace the CMOS battery in multiple computers because I use them for so long that the batteries do fail. 209.149.113.5 (talk) 19:45, 11 June 2018 (UTC)
- Our article real-time clock says:
Computers used as local time servers occasionally use GPS or ultra-low frequency digital radio transmissions broadcast by a national standards organization (i.e. a radio clock).
However "radio clock" says that the only signals used are transmitted by either shortwave or longwave radio transmitters. This is because the buffering used in digital transmission delays the signal unpredictably. The National Institute of Science and Technology says the low frequency transmissions are analogue [1]. This is confirmed in the Application Note put out by Hewlett Packard [2] (at p. 72). Is there an error in one of the articles? 86.131.233.241 (talk) 19:23, 12 June 2018 (UTC)
How do I make a file extension unrecognized again in Windows?
editI had some files with an extension unknown to Windows so it asked me what program to open it with. I picked Notepad just to see what was in there. Now obviously Windows always opens files with that extension with Notepad. But I want to change that back to how it was before: I want to make that extension unrecognized back again the way it was, not change it so that it opens by default with some other installed program. Is there a way to do that? Basemetal 22:34, 9 June 2018 (UTC)
- A search for "windows remove file association" yielded "7 Ways To to Remove a File Extension Association in Windows" as the top hit. The first four methods require add-ins, but the remaining ones do not. -- Tom N talk/contrib 04:30, 10 June 2018 (UTC)
- Thanks but for some reason it didn't work. Even though in the Command Prompt "assoc" says file extension .foo is now associated with no program ("File association not found for extension .foo") Windows still opens it with Notepad or Wordpad or whatever program I change it too. I also opened the registry with "regedit". The file extension ".foo" was still there. I deleted it. I hope this won't cause any problem. (I'll find out I guess). And Windows still does the same thing. I'm gonna try to use the third method, namely associating it with a program I subsequently delete. We'll see if that will work. Basemetal 05:45, 10 June 2018 (UTC) It isn't necessary to delete extension ".foo" from the registry. It is enough to associate with no string and "assoc" will still say "File association not found for extension .foo". So I recreated the key and associated with no string which gives exactly the same result as before: .foo files still open with Notepad etc.
- The 3rd method, namely associating file extension .foo with a program that you then delete does work. Interesting. Basemetal 06:32, 10 June 2018 (UTC)
Is there a way to play my MIDI sound module from Python in Windows?
editThe Python library has a module for accessing MIDI devices, namely ossaudiodev but that apparently only exists for Linux. On the other hand the Windows specific module winsound from what I can tell only deals with raw audio, not MIDI. Does the standard Windows version of Python have a module for accessing MIDI devices? If not do you know of modules developped by third parties that allow you to do that? Thanks. Basemetal 22:57, 9 June 2018 (UTC)